Changeset 3834 for extensions/PiwigoLib/PiwigoLib/Proxy
- Timestamp:
- Sep 7, 2009, 2:46:08 PM (15 years ago)
- Location:
- extensions/PiwigoLib/PiwigoLib/Proxy
- Files:
-
- 3 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
extensions/PiwigoLib/PiwigoLib/Proxy/Helper/PwgProxyReponseHelper.cs
r3827 r3834 7 7 namespace Com.Piwigo.Lib.Proxy.Helper 8 8 { 9 public static class PwgProxyReponseHelper <T>9 public static class PwgProxyReponseHelper 10 10 { 11 public static void buildQueryFromArray (List<T> values, String paramName, ref Boolean firstOcc, StringBuilder queryStringBuilder)11 public static void buildQueryFromArray<T>(List<T> values, String paramName, ref Boolean firstOcc, StringBuilder queryStringBuilder) 12 12 { 13 13 String FormatString = String.Empty; … … 34 34 35 35 } 36 } 36 37 38 public static void buildQueryFromValue<T>(Nullable<T> nullableValue, String paramName, ref Boolean firstOcc, StringBuilder queryStringBuilder) 39 where T: struct 40 { 41 if (nullableValue.HasValue) 42 { 43 buildQueryFromValue<T>(nullableValue.Value, paramName, ref firstOcc, queryStringBuilder); 44 } 45 } 46 47 public static void buildQueryFromValue<T>(T value, String paramName, ref Boolean firstOcc, StringBuilder queryStringBuilder) 48 { 49 String FormatString = String.Empty; 50 if (value != null) 51 { 52 FormatString = "{0}={1}"; 53 if (firstOcc != true) 54 { 55 FormatString = String.Format("&{0}", FormatString); 56 } 57 58 queryStringBuilder.AppendFormat(FormatString, paramName, HttpUtility.UrlEncode(value.ToString().ToLower())); 59 firstOcc = false; 60 } 37 61 } 38 62 } -
extensions/PiwigoLib/PiwigoLib/Proxy/PwgCategoriesProxy.cs
r3833 r3834 10 10 namespace Com.Piwigo.Lib.Proxy 11 11 { 12 static class Pwg TagsProxy12 static class PwgCategoriesProxy 13 13 { 14 static public PwgTagsProxyResponse pwg_tags_getList(Boolean sortedByCounter) 14 static public PwgCategoriesProxyResponse pwg_categories_getList(Int32? CategoryId, 15 Boolean? Recursive, Boolean? PublicOnly) 15 16 { 16 Pwg TagsProxyResponse response = null;17 PwgCategoriesProxyResponse response = null; 17 18 try 18 19 { 19 20 StringBuilder data = new StringBuilder(); 20 data.Append("sort_by_counter=" + HttpUtility.UrlEncode(sortedByCounter.ToString().ToLower()));21 Boolean firstOcc = true; 21 22 22 response = PwgGenericProxy<PwgTagsProxyResponse>.Get( 23 PwgProxyReponseHelper.buildQueryFromValue<Int32>(CategoryId, "cat_id", ref firstOcc, data); 24 PwgProxyReponseHelper.buildQueryFromValue<Boolean>(Recursive, "recursive", ref firstOcc, data); 25 PwgProxyReponseHelper.buildQueryFromValue<Boolean>(PublicOnly, "public", ref firstOcc, data); 26 27 response = PwgGenericProxy<PwgCategoriesProxyResponse>.Get( 23 28 PwgConfigProxy.PwgServeurUriBuilder.Uri, 24 "pwg. tags.getList", data.ToString());29 "pwg.categories.getList", data.ToString()); 25 30 } 26 31 catch (Exception ex) 27 32 { 28 throw new PwgProxyException("pwg_ tags_getList", ex);33 throw new PwgProxyException("pwg_categories_getList", ex); 29 34 } 30 35 return response; … … 32 37 } 33 38 34 static public Pwg TagsProxyResponse pwg_tags_getAdminList()39 static public PwgCategoriesProxyResponse pwg_categories_getAdminList() 35 40 { 36 Pwg TagsProxyResponse response = null;41 PwgCategoriesProxyResponse response = null; 37 42 try 38 43 { 39 response = PwgGenericProxy<Pwg TagsProxyResponse>.Get(44 response = PwgGenericProxy<PwgCategoriesProxyResponse>.Get( 40 45 PwgConfigProxy.PwgServeurUriBuilder.Uri, 41 "pwg. tags.getAdminList", null);46 "pwg.categories.getAdminList", null); 42 47 } 43 48 catch (Exception ex) 44 49 { 45 throw new PwgProxyException("pwg_ tags_getAdminList", ex);50 throw new PwgProxyException("pwg_categories_getAdminList", ex); 46 51 } 47 52 return response; … … 49 54 } 50 55 51 static public PwgImagesProxyResponse pwg_tags_getImages(List<Int32> tagsId, 52 List<String> tagsUrlName, 53 List<String> tagsName, 54 Boolean? tagModeAnd, 55 Int32? perPage, 56 Int32? Page, 57 Int32? Order, 58 Int32? minRate, 59 Int32? maxRate, 60 Int32? minHit, 61 Int32? maxHit, 62 DateTime? minDateAvailable, 63 DateTime? maxDateAvailable, 64 DateTime? minDateCreated, 65 DateTime? maxDateCreated, 66 Int32? minRatio, 67 Int32? maxRatio, 68 Boolean? withThumbnail) 56 static public PwgAddRequestProxyResponse pwg_categories_add(String categorieName, Int32? IdUpperCat) 69 57 { 70 Pwg ImagesProxyResponse response = null;58 PwgAddRequestProxyResponse response = null; 71 59 try 72 60 { 73 61 StringBuilder data = new StringBuilder(); 74 Boolean firstOcc = true; 75 data.AppendFormat("method={0}","pwg.tags.getImages"); 76 firstOcc = false; 77 PwgProxyReponseHelper<Int32>.buildQueryFromArray(tagsId, "tag_id", ref firstOcc, data); 78 PwgProxyReponseHelper<String>.buildQueryFromArray(tagsUrlName, "tag_url_name", ref firstOcc, data); 79 PwgProxyReponseHelper<String>.buildQueryFromArray(tagsName, "tag_name", ref firstOcc, data); 62 data.Append("method=pwg.categories.add"); 63 Boolean firstOcc = false; 64 PwgProxyReponseHelper.buildQueryFromValue<String>(categorieName, "name", ref firstOcc, data); 65 PwgProxyReponseHelper.buildQueryFromValue<Int32>(IdUpperCat, "parent", ref firstOcc, data); 80 66 81 if (tagModeAnd.HasValue) 82 { 83 data.Append("&tag_mode_and=" + HttpUtility.UrlEncode(tagModeAnd.ToString().ToLower())); 84 } 85 if (perPage.HasValue) 86 { 87 data.Append("&per_page=" + HttpUtility.UrlEncode(perPage.ToString().ToLower())); 88 } 89 if (Page.HasValue) 90 { 91 data.Append("&page=" + HttpUtility.UrlEncode(Page.ToString().ToLower())); 92 } 93 if (Order.HasValue) 94 { 95 data.Append("&order=" + HttpUtility.UrlEncode(Order.ToString().ToLower())); 96 } 97 if (minRate.HasValue) 98 { 99 data.Append("&f_min_rate=" + HttpUtility.UrlEncode(minRate.ToString().ToLower())); 100 } 101 if (maxRate.HasValue) 102 { 103 data.Append("&f_max_rate=" + HttpUtility.UrlEncode(maxRate.ToString().ToLower())); 104 } 105 if (minHit.HasValue) 106 { 107 data.Append("&f_min_hit=" + HttpUtility.UrlEncode(minHit.ToString().ToLower())); 108 } 109 if (maxHit.HasValue) 110 { 111 data.Append("&f_max_hit=" + HttpUtility.UrlEncode(maxHit.ToString().ToLower())); 112 } 113 if (minDateAvailable.HasValue) 114 { 115 data.Append("&f_min_date_available=" + HttpUtility.UrlEncode(minDateAvailable.ToString().ToLower())); 116 } 117 if (maxDateAvailable.HasValue) 118 { 119 data.Append("&f_max_date_available=" + HttpUtility.UrlEncode(maxDateAvailable.ToString().ToLower())); 120 } 121 if (minDateCreated.HasValue) 122 { 123 data.Append("&f_min_date_created=" + HttpUtility.UrlEncode(minDateCreated.ToString().ToLower())); 124 } 125 if (maxDateCreated.HasValue) 126 { 127 data.Append("&f_max_date_created=" + HttpUtility.UrlEncode(maxDateCreated.ToString().ToLower())); 128 } 129 if (minRatio.HasValue) 130 { 131 data.Append("&f_min_ratio=" + HttpUtility.UrlEncode(minRatio.ToString().ToLower())); 132 } 133 if (maxRatio.HasValue) 134 { 135 data.Append("&f_max_ratio=" + HttpUtility.UrlEncode(maxRatio.ToString().ToLower())); 136 } 137 if (withThumbnail.HasValue) 138 { 139 data.Append("&f_with_thumbnail=" + HttpUtility.UrlEncode(withThumbnail.ToString().ToLower())); 140 } 141 142 response = PwgGenericProxy<PwgImagesProxyResponse>.Post( 143 PwgConfigProxy.PwgServeurUriBuilder.Uri, 144 data.ToString()); 145 } 146 catch (Exception ex) 147 { 148 throw new PwgProxyException("pwg_tags_getImages", ex); 149 } 150 return response; 151 152 } 153 static public PwgTagsProxyResponse pwg_tag_add(string tagName) 154 { 155 PwgTagsProxyResponse response = null; 156 try 157 { 158 StringBuilder data = new StringBuilder(); 159 data.Append("method=pwg.tags.add"); 160 data.Append("&name=" + HttpUtility.UrlEncode(tagName)); 161 162 response = PwgGenericProxy<PwgTagsProxyResponse>.Post( 67 response = PwgGenericProxy<PwgAddRequestProxyResponse>.Post( 163 68 PwgConfigProxy.PwgServeurUriBuilder.Uri, 164 69 data.ToString()); … … 166 71 catch (Exception ex) 167 72 { 168 throw new PwgProxyException("pwg_ tag_add", ex);73 throw new PwgProxyException("pwg_categories_add", ex); 169 74 } 170 75 … … 172 77 } 173 78 79 174 80 } 175 81 -
extensions/PiwigoLib/PiwigoLib/Proxy/PwgTagsProxy.cs
r3827 r3834 12 12 static class PwgTagsProxy 13 13 { 14 static public PwgTagsProxyResponse pwg_tags_getList(Boolean sortedByCounter)14 static public PwgTagsProxyResponse pwg_tags_getList(Boolean? sortedByCounter) 15 15 { 16 16 PwgTagsProxyResponse response = null; … … 18 18 { 19 19 StringBuilder data = new StringBuilder(); 20 data.Append("sort_by_counter=" + HttpUtility.UrlEncode(sortedByCounter.ToString().ToLower())); 20 Boolean firstOcc = true; 21 22 PwgProxyReponseHelper.buildQueryFromValue<Boolean>(sortedByCounter, "sort_by_counter", ref firstOcc, data); 21 23 22 24 response = PwgGenericProxy<PwgTagsProxyResponse>.Get( … … 55 57 Int32? perPage, 56 58 Int32? Page, 57 Int32? Order,59 Int32? Order, 58 60 Int32? minRate, 59 61 Int32? maxRate, … … 75 77 data.AppendFormat("method={0}","pwg.tags.getImages"); 76 78 firstOcc = false; 77 PwgProxyReponseHelper <Int32>.buildQueryFromArray(tagsId, "tag_id", ref firstOcc, data);78 PwgProxyReponseHelper <String>.buildQueryFromArray(tagsUrlName, "tag_url_name", ref firstOcc, data);79 PwgProxyReponseHelper <String>.buildQueryFromArray(tagsName, "tag_name", ref firstOcc, data);79 PwgProxyReponseHelper.buildQueryFromArray<Int32>(tagsId, "tag_id", ref firstOcc, data); 80 PwgProxyReponseHelper.buildQueryFromArray<String>(tagsUrlName, "tag_url_name", ref firstOcc, data); 81 PwgProxyReponseHelper.buildQueryFromArray<String>(tagsName, "tag_name", ref firstOcc, data); 80 82 81 if (tagModeAnd.HasValue) 82 { 83 data.Append("&tag_mode_and=" + HttpUtility.UrlEncode(tagModeAnd.ToString().ToLower())); 84 } 85 if (perPage.HasValue) 86 { 87 data.Append("&per_page=" + HttpUtility.UrlEncode(perPage.ToString().ToLower())); 88 } 89 if (Page.HasValue) 90 { 91 data.Append("&page=" + HttpUtility.UrlEncode(Page.ToString().ToLower())); 92 } 93 if (Order.HasValue) 94 { 95 data.Append("&order=" + HttpUtility.UrlEncode(Order.ToString().ToLower())); 96 } 97 if (minRate.HasValue) 98 { 99 data.Append("&f_min_rate=" + HttpUtility.UrlEncode(minRate.ToString().ToLower())); 100 } 101 if (maxRate.HasValue) 102 { 103 data.Append("&f_max_rate=" + HttpUtility.UrlEncode(maxRate.ToString().ToLower())); 104 } 105 if (minHit.HasValue) 106 { 107 data.Append("&f_min_hit=" + HttpUtility.UrlEncode(minHit.ToString().ToLower())); 108 } 109 if (maxHit.HasValue) 110 { 111 data.Append("&f_max_hit=" + HttpUtility.UrlEncode(maxHit.ToString().ToLower())); 112 } 113 if (minDateAvailable.HasValue) 114 { 115 data.Append("&f_min_date_available=" + HttpUtility.UrlEncode(minDateAvailable.ToString().ToLower())); 116 } 117 if (maxDateAvailable.HasValue) 118 { 119 data.Append("&f_max_date_available=" + HttpUtility.UrlEncode(maxDateAvailable.ToString().ToLower())); 120 } 121 if (minDateCreated.HasValue) 122 { 123 data.Append("&f_min_date_created=" + HttpUtility.UrlEncode(minDateCreated.ToString().ToLower())); 124 } 125 if (maxDateCreated.HasValue) 126 { 127 data.Append("&f_max_date_created=" + HttpUtility.UrlEncode(maxDateCreated.ToString().ToLower())); 128 } 129 if (minRatio.HasValue) 130 { 131 data.Append("&f_min_ratio=" + HttpUtility.UrlEncode(minRatio.ToString().ToLower())); 132 } 133 if (maxRatio.HasValue) 134 { 135 data.Append("&f_max_ratio=" + HttpUtility.UrlEncode(maxRatio.ToString().ToLower())); 136 } 137 if (withThumbnail.HasValue) 138 { 139 data.Append("&f_with_thumbnail=" + HttpUtility.UrlEncode(withThumbnail.ToString().ToLower())); 140 } 83 PwgProxyReponseHelper.buildQueryFromValue<Boolean>(tagModeAnd, "tag_mode_and", ref firstOcc, data); 84 PwgProxyReponseHelper.buildQueryFromValue<Int32>(perPage, "per_page", ref firstOcc, data); 85 PwgProxyReponseHelper.buildQueryFromValue<Int32>(Page, "page", ref firstOcc, data); 86 PwgProxyReponseHelper.buildQueryFromValue<Int32>(Order, "order", ref firstOcc, data); 87 PwgProxyReponseHelper.buildQueryFromValue<Int32>(minRate, "f_min_rate", ref firstOcc, data); 88 PwgProxyReponseHelper.buildQueryFromValue<Int32>(maxRate, "f_max_rate", ref firstOcc, data); 89 PwgProxyReponseHelper.buildQueryFromValue<Int32>(minHit, "f_min_hit", ref firstOcc, data); 90 PwgProxyReponseHelper.buildQueryFromValue<Int32>(maxHit, "f_max_hit", ref firstOcc, data); 91 PwgProxyReponseHelper.buildQueryFromValue<DateTime>(minDateAvailable, "f_min_date_available", ref firstOcc, data); 92 PwgProxyReponseHelper.buildQueryFromValue<DateTime>(maxDateAvailable, "f_max_date_available", ref firstOcc, data); 93 PwgProxyReponseHelper.buildQueryFromValue<DateTime>(minDateCreated, "f_min_date_created", ref firstOcc, data); 94 PwgProxyReponseHelper.buildQueryFromValue<DateTime>(maxDateCreated, "f_max_date_created", ref firstOcc, data); 95 PwgProxyReponseHelper.buildQueryFromValue<Int32>(minRatio, "f_min_ratio", ref firstOcc, data); 96 PwgProxyReponseHelper.buildQueryFromValue<Int32>(maxRatio, "f_max_ratio", ref firstOcc, data); 97 PwgProxyReponseHelper.buildQueryFromValue<Boolean>(withThumbnail, "f_with_thumbnail", ref firstOcc, data); 141 98 142 99 response = PwgGenericProxy<PwgImagesProxyResponse>.Post( … … 151 108 152 109 } 153 static public Pwg TagsProxyResponse pwg_tag_add(string tagName)110 static public PwgAddRequestProxyResponse pwg_tag_add(string tagName) 154 111 { 155 Pwg TagsProxyResponse response = null;112 PwgAddRequestProxyResponse response = null; 156 113 try 157 114 { … … 160 117 data.Append("&name=" + HttpUtility.UrlEncode(tagName)); 161 118 162 response = PwgGenericProxy<Pwg TagsProxyResponse>.Post(119 response = PwgGenericProxy<PwgAddRequestProxyResponse>.Post( 163 120 PwgConfigProxy.PwgServeurUriBuilder.Uri, 164 121 data.ToString()); -
extensions/PiwigoLib/PiwigoLib/Proxy/Response/PwgAddRequestProxyResponse.cs
r3833 r3834 9 9 { 10 10 [Serializable()] 11 [XmlRoot(ElementName = " tag")]12 public class Pwg TagProxyResponse11 [XmlRoot(ElementName = "rsp")] 12 public class PwgAddRequestProxyResponse : PwgBaseProxyReponse 13 13 { 14 [XmlAttribute(AttributeName = "id")] 15 public Int32 Id { get; set; } 16 [XmlAttribute(AttributeName = "name")] 17 public String Name { get; set; } 18 [XmlAttribute(AttributeName = "url_name")] 19 public String UrlName { get; set; } 20 [XmlAttribute(AttributeName = "counter")] 21 public Int64 Counter { get; set; } 22 [XmlAttribute(AttributeName = "url")] 23 public String UrlTag { get; set; } 24 } 14 [XmlElement(ElementName="info")] 15 public String Message { get; set; } 16 [XmlElement(ElementName = "id")] 17 public Int32 NewId { get; set; } 25 18 26 [Serializable()]27 [XmlRoot(ElementName = "rsp")]28 public class PwgTagsProxyResponse : PwgBaseProxyReponse29 {30 //[XmlElement(ElementName = "tags")]31 [XmlArray("tags")]32 [XmlArrayItem("tag")]33 public PwgTagProxyResponse[] Tags { get; set; }34 19 } 35 20 } -
extensions/PiwigoLib/PiwigoLib/Proxy/Response/PwgCategoriesProxyResponse.cs
r3827 r3834 9 9 { 10 10 [Serializable()] 11 [XmlRoot(ElementName = "categor ies")]11 [XmlRoot(ElementName = "category")] 12 12 public class PwgCategoryProxyResponse 13 13 { 14 14 [XmlAttribute(AttributeName = "id")] 15 15 public Int32 Id { get; set; } 16 [XmlAttribute(AttributeName = "name")] 16 [XmlElement(ElementName = "uppercats")] 17 public String UpperCategoryId { get; set; } 18 [XmlElement (ElementName = "name")] 17 19 public String Name { get; set; } 18 [XmlAttribute(AttributeName = "url_name")]19 public String UrlName { get; set; }20 [XmlAttribute(AttributeName = "counter")]21 public Int64 Counter { get; set; }22 20 [XmlAttribute(AttributeName = "url")] 23 public String UrlTag { get; set; } 21 public String Url { get; set; } 22 [XmlAttribute(AttributeName = "nb_images")] 23 public Int64 ImagesCount { get; set; } 24 [XmlAttribute(AttributeName = "total_nb_images")] 25 public Int64 DeepImagesCount { get; set; } 26 [XmlAttribute(AttributeName = "nb_categories")] 27 public Int64 SubCategoriesCount { get; set; } 28 [XmlAttribute(AttributeName = "max_date_last")] 29 public String LastDate { get; set; } 24 30 } 25 31 26 32 [Serializable()] 27 33 [XmlRoot(ElementName = "rsp")] 28 public class Pwg categoriesProxyResponse : PwgBaseProxyReponse34 public class PwgCategoriesProxyResponse : PwgBaseProxyReponse 29 35 { 30 36 [XmlArray("categories")]
Note: See TracChangeset
for help on using the changeset viewer.