Changeset 3835
- Timestamp:
- Sep 7, 2009, 3:54:31 PM (15 years ago)
- Location:
- extensions/PiwigoLib
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/PiwigoLib/PiwigoLib/DTO/PwgImage.cs
r3827 r3835 20 20 public List<PwgTag> Tags { get; set; } 21 21 22 public List<PwgCategory> Categories { get; set; } 23 22 24 } 23 25 } -
extensions/PiwigoLib/PiwigoLib/Proxy/PwgCategoriesProxy.cs
r3834 r3835 12 12 static class PwgCategoriesProxy 13 13 { 14 /// <summary> 15 /// pwg.categories.getList 16 /// </summary> 17 /// <param name="CategoryId"></param> 18 /// <param name="Recursive"></param> 19 /// <param name="PublicOnly"></param> 20 /// <returns></returns> 14 21 static public PwgCategoriesProxyResponse pwg_categories_getList(Int32? CategoryId, 15 22 Boolean? Recursive, Boolean? PublicOnly) … … 37 44 } 38 45 46 /// <summary> 47 /// pwg.categories.getAdminList 48 /// </summary> 49 /// <returns></returns> 39 50 static public PwgCategoriesProxyResponse pwg_categories_getAdminList() 40 51 { … … 54 65 } 55 66 67 /// <summary> 68 /// pwg.categories.add 69 /// </summary> 70 /// <param name="categorieName"></param> 71 /// <param name="IdUpperCat"></param> 72 /// <returns></returns> 56 73 static public PwgAddRequestProxyResponse pwg_categories_add(String categorieName, Int32? IdUpperCat) 57 74 { … … 77 94 } 78 95 96 /// <summary> 97 /// pwg.categories.setInfo 98 /// </summary> 99 /// <param name="IdCat"></param> 100 /// <param name="categorieName"></param> 101 /// <param name="categorieComment"></param> 102 /// <returns></returns> 103 static public PwgBaseProxyReponse pwg_categories_setInfo(Int32 IdCat, String categorieName, String categorieComment) 104 { 105 PwgBaseProxyReponse response = null; 106 try 107 { 108 StringBuilder data = new StringBuilder(); 109 data.Append("method=pwg.categories.setInfo"); 110 Boolean firstOcc = false; 111 PwgProxyReponseHelper.buildQueryFromValue<Int32>(IdCat, "category_id", ref firstOcc, data); 112 PwgProxyReponseHelper.buildQueryFromValue<String>(categorieName, "name", ref firstOcc, data); 113 PwgProxyReponseHelper.buildQueryFromValue<String>(categorieComment, "comment", ref firstOcc, data); 114 115 response = PwgGenericProxy<PwgAddRequestProxyResponse>.Post( 116 PwgConfigProxy.PwgServeurUriBuilder.Uri, 117 data.ToString()); 118 } 119 catch (Exception ex) 120 { 121 throw new PwgProxyException("pwg_categories_setInfo", ex); 122 } 123 124 return response; 125 } 126 127 /// <summary> 128 /// pwg.categories.getImages 129 /// </summary> 130 /// <param name="catId"></param> 131 /// <param name="recursive"></param> 132 /// <param name="perPage"></param> 133 /// <param name="Page"></param> 134 /// <param name="Order"></param> 135 /// <param name="minRate"></param> 136 /// <param name="maxRate"></param> 137 /// <param name="minHit"></param> 138 /// <param name="maxHit"></param> 139 /// <param name="minDateAvailable"></param> 140 /// <param name="maxDateAvailable"></param> 141 /// <param name="minDateCreated"></param> 142 /// <param name="maxDateCreated"></param> 143 /// <param name="minRatio"></param> 144 /// <param name="maxRatio"></param> 145 /// <param name="withThumbnail"></param> 146 /// <returns></returns> 147 static public PwgImagesProxyResponse pwg_categories_getImages(Int32 catId, 148 Boolean? recursive, 149 Int32? perPage, 150 Int32? Page, 151 Int32? Order, 152 Int32? minRate, 153 Int32? maxRate, 154 Int32? minHit, 155 Int32? maxHit, 156 DateTime? minDateAvailable, 157 DateTime? maxDateAvailable, 158 DateTime? minDateCreated, 159 DateTime? maxDateCreated, 160 Int32? minRatio, 161 Int32? maxRatio, 162 Boolean? withThumbnail) 163 { 164 PwgImagesProxyResponse response = null; 165 try 166 { 167 StringBuilder data = new StringBuilder(); 168 Boolean firstOcc = true; 169 data.AppendFormat("method={0}", "pwg.categories.getImages"); 170 firstOcc = false; 171 PwgProxyReponseHelper.buildQueryFromValue<Int32>(catId, "cat_id", ref firstOcc, data); 172 173 PwgProxyReponseHelper.buildQueryFromValue<Boolean>(recursive, "recursive", ref firstOcc, data); 174 PwgProxyReponseHelper.buildQueryFromValue<Int32>(perPage, "per_page", ref firstOcc, data); 175 PwgProxyReponseHelper.buildQueryFromValue<Int32>(Page, "page", ref firstOcc, data); 176 PwgProxyReponseHelper.buildQueryFromValue<Int32>(Order, "order", ref firstOcc, data); 177 PwgProxyReponseHelper.buildQueryFromValue<Int32>(minRate, "f_min_rate", ref firstOcc, data); 178 PwgProxyReponseHelper.buildQueryFromValue<Int32>(maxRate, "f_max_rate", ref firstOcc, data); 179 PwgProxyReponseHelper.buildQueryFromValue<Int32>(minHit, "f_min_hit", ref firstOcc, data); 180 PwgProxyReponseHelper.buildQueryFromValue<Int32>(maxHit, "f_max_hit", ref firstOcc, data); 181 PwgProxyReponseHelper.buildQueryFromValue<DateTime>(minDateAvailable, "f_min_date_available", ref firstOcc, data); 182 PwgProxyReponseHelper.buildQueryFromValue<DateTime>(maxDateAvailable, "f_max_date_available", ref firstOcc, data); 183 PwgProxyReponseHelper.buildQueryFromValue<DateTime>(minDateCreated, "f_min_date_created", ref firstOcc, data); 184 PwgProxyReponseHelper.buildQueryFromValue<DateTime>(maxDateCreated, "f_max_date_created", ref firstOcc, data); 185 PwgProxyReponseHelper.buildQueryFromValue<Int32>(minRatio, "f_min_ratio", ref firstOcc, data); 186 PwgProxyReponseHelper.buildQueryFromValue<Int32>(maxRatio, "f_max_ratio", ref firstOcc, data); 187 PwgProxyReponseHelper.buildQueryFromValue<Boolean>(withThumbnail, "f_with_thumbnail", ref firstOcc, data); 188 189 response = PwgGenericProxy<PwgImagesProxyResponse>.Post( 190 PwgConfigProxy.PwgServeurUriBuilder.Uri, 191 data.ToString()); 192 } 193 catch (Exception ex) 194 { 195 throw new PwgProxyException("pwg_categories_getImages", ex); 196 } 197 return response; 198 199 } 200 201 /// <summary> 202 /// 203 /// </summary> 204 /// <param name="tagName"></param> 205 /// <returns></returns> 206 static public PwgAddRequestProxyResponse pwg_tag_add(string tagName) 207 { 208 PwgAddRequestProxyResponse response = null; 209 try 210 { 211 StringBuilder data = new StringBuilder(); 212 data.Append("method=pwg.tags.add"); 213 data.Append("&name=" + HttpUtility.UrlEncode(tagName)); 214 215 response = PwgGenericProxy<PwgAddRequestProxyResponse>.Post( 216 PwgConfigProxy.PwgServeurUriBuilder.Uri, 217 data.ToString()); 218 } 219 catch (Exception ex) 220 { 221 throw new PwgProxyException("pwg_tag_add", ex); 222 } 223 224 return response; 225 } 79 226 80 227 } -
extensions/PiwigoLib/PiwigoLib/Proxy/Response/PwgImagesProxyResponse.cs
r3827 r3835 33 33 public PwgTagProxyResponse[] Tags { get; set; } 34 34 35 [XmlArray("categories")] 36 [XmlArrayItem("category")] 37 public PwgCategoryProxyResponse[] Categories { get; set; } 38 35 39 } 36 40 -
extensions/PiwigoLib/PiwigoLib/Service/PwgCategoriesService.cs
r3834 r3835 89 89 90 90 /// <summary> 91 /// Add a Categorie 92 /// </summary> 93 /// <param name="tagName"></param> 94 /// <returns></returns> 91 /// Add a category to the gallery 92 /// </summary> 93 /// <param name="categoryName"></param> 94 /// <param name="upperCatId"></param> 95 /// <param name="newId"> Id used by the new category</param> 96 /// <param name="messageInfo">Message returned by the server</param> 97 /// <returns>false, if a error occurs</returns> 95 98 static public Boolean AddCategory(String categoryName, Int32? upperCatId, ref Int32 newId, ref String messageInfo) 96 99 { … … 105 108 if (response.Erreur != null) 106 109 { 107 throw new PwgServiceException("Add Tag, the server has return the error.",108 response.Erreur.Code, 109 response.Erreur.Message); 110 } 111 else 112 { 113 throw new PwgServiceException("Add Tag: a error occurs during server process.");110 throw new PwgServiceException("AddCategory, the server has return the error.", 111 response.Erreur.Code, 112 response.Erreur.Message); 113 } 114 else 115 { 116 throw new PwgServiceException("AddCategory : a error occurs during server process."); 114 117 } 115 118 } … … 123 126 catch (PwgProxyException ex) 124 127 { 125 throw new PwgServiceException("AddTag : a error is raised by proxy.", ex); 126 } 127 return returnValue; 128 } 129 130 /// <summary> 131 /// private: convert response to dto object 128 throw new PwgServiceException("AddCategory : a error is raised by proxy.", ex); 129 } 130 return returnValue; 131 } 132 133 static public List<PwgImage> GetListOfImagesFormCategory(Int32 categoryId, 134 Boolean? recursive, 135 Int32? perPage, 136 Int32? Page, 137 Int32? Order, 138 Int32? minRate, 139 Int32? maxRate, 140 Int32? minHit, 141 Int32? maxHit, 142 DateTime? minDateAvailable, 143 DateTime? maxDateAvailable, 144 DateTime? minDateCreated, 145 DateTime? maxDateCreated, 146 Int32? minRatio, 147 Int32? maxRatio, 148 Boolean? withThumbnail, 149 ref Int32 PageReturned, 150 ref Int32 PerPageeReturned, 151 ref Int32 CountReturned) 152 { 153 List<PwgImage> returnValue = new List<PwgImage>(); 154 155 try 156 { 157 PwgImagesProxyResponse response = PwgCategoriesProxy.pwg_categories_getImages(categoryId, 158 recursive, 159 perPage, 160 Page, 161 Order, 162 minRate, 163 maxRate, 164 minHit, 165 maxHit, 166 minDateAvailable, 167 maxDateAvailable, 168 minDateCreated, 169 maxDateCreated, 170 minRatio, 171 maxRatio, 172 withThumbnail); 173 174 if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok) 175 { 176 if (response.Erreur != null) 177 { 178 throw new PwgServiceException("GetListOfImagesFormCategory, the server has return the error.", 179 response.Erreur.Code, 180 response.Erreur.Message); 181 } 182 else 183 { 184 throw new PwgServiceException("GetListOfImagesFormCategory : a error occurs during server process."); 185 } 186 } 187 else 188 { 189 PwgImagesService.ConvertProxyResponseToDTO(response, returnValue, 190 ref PageReturned, 191 ref PerPageeReturned, 192 ref CountReturned); 193 } 194 } 195 catch (PwgProxyException ex) 196 { 197 throw new PwgServiceException("GetListOfImagesFormCategory : a error is raised by proxy.", ex); 198 } 199 return returnValue; 200 } 201 202 /// <summary> 203 /// convert response to dto object 132 204 /// </summary> 133 205 /// <param name="response"></param> … … 147 219 148 220 /// <summary> 149 /// private:convert response to dto object221 /// convert response to dto object 150 222 /// </summary> 151 223 /// <param name="response"></param> -
extensions/PiwigoLib/PiwigoLib/Service/PwgImagesService.cs
r3828 r3835 38 38 Count = response.Count; 39 39 40 foreach (PwgImageProxyResponse respImg in response.Images)40 if (response.Images != null) 41 41 { 42 lstImage.Add(ConvertProxyResponseToDTO(respImg)); 42 foreach (PwgImageProxyResponse respImg in response.Images) 43 { 44 lstImage.Add(ConvertProxyResponseToDTO(respImg)); 45 } 43 46 } 44 47 } … … 89 92 90 93 returnValue.Tags = new List<PwgTag>(); 91 foreach (PwgTagProxyResponse tagResp in response.Tags)94 if (response.Tags != null) 92 95 { 93 PwgTag aTag = PwgTagsService.ConvertProxyResponseToDTO(tagResp); 94 returnValue.Tags.Add(aTag); 96 foreach (PwgTagProxyResponse tagResp in response.Tags) 97 { 98 PwgTag aTag = PwgTagsService.ConvertProxyResponseToDTO(tagResp); 99 returnValue.Tags.Add(aTag); 100 } 101 } 102 103 returnValue.Categories = new List<PwgCategory>(); 104 if (response.Categories != null) 105 { 106 foreach (PwgCategoryProxyResponse catResp in response.Categories) 107 { 108 PwgCategory aCat = PwgCategoriesService.ConvertProxyResponseToDTO(catResp); 109 returnValue.Categories.Add(aCat); 110 } 95 111 } 96 112 -
extensions/PiwigoLib/TestPiwigoLib/Form1.cs
r3834 r3835 49 49 //List<PwgTag> lstTag = PwgTagsService.GetAdminListOfTag(); 50 50 51 //Int32 Page = 0;52 //Int32 PerPage = 0;53 //Int32 Count = 0;51 Int32 Page = 0; 52 Int32 PerPage = 0; 53 Int32 Count = 0; 54 54 55 55 //List<PwgImage> lstImg = PwgTagsService.GetListOfImagesFormTags(new List<Int32>() { 1, 7 }, … … 57 57 // ref Page, ref PerPage, ref Count); 58 58 59 List<PwgImage> lstImg = PwgCategoriesService.GetListOfImagesFormCategory(1, 60 null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 61 ref Page, ref PerPage, ref Count); 62 59 63 //Console.WriteLine("lstImg : Page " + Page.ToString() + " PerPage " + PerPage); 60 64 61 List<PwgCategory> lstCat = PwgCategoriesService.GetAdminListOfCategory();65 //List<PwgCategory> lstCat = PwgCategoriesService.GetAdminListOfCategory(); 62 66 63 67
Note: See TracChangeset
for help on using the changeset viewer.