Changeset 3834
- Timestamp:
- Sep 7, 2009, 2:46:08 PM (15 years ago)
- Location:
- extensions/PiwigoLib
- Files:
-
- 6 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
extensions/PiwigoLib/PiwigoLib/DTO/PwgCategory.cs
r3833 r3834 7 7 { 8 8 9 public class Pwg Tag9 public class PwgCategory 10 10 { 11 public Int32 Id { get; set; } 12 public String Name { get; set; } 13 public String UrlName { get; set; } 14 public Int64 Counter { get; set; } 15 public Uri UrlTag { get; set; } 11 public Int32 Id { get; set; } 12 public List<Int32> UpperCategoriesId { get; set; } 13 public String Name { get; set; } 14 public Uri Url { get; set; } 15 public Int64 ImagesCount { get; set; } 16 public Int64 DeepImagesCount { get; set; } 17 public Int64 SubCategoriesCount { get; set; } 18 public DateTime LastDate { get; set; } 16 19 } 17 20 } -
extensions/PiwigoLib/PiwigoLib/PiwigoLib.csproj
r3827 r3834 4 4 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> 5 5 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> 6 <ProductVersion>9.0. 21022</ProductVersion>6 <ProductVersion>9.0.30729</ProductVersion> 7 7 <SchemaVersion>2.0</SchemaVersion> 8 8 <ProjectGuid>{64C068C5-DBFE-4712-9081-B9100698F35C}</ProjectGuid> … … 47 47 </ItemGroup> 48 48 <ItemGroup> 49 <Compile Include="DTO\PwgCategory.cs" /> 49 50 <Compile Include="DTO\PwgImage.cs" /> 50 51 <Compile Include="DTO\Helper\PwgEnumHelper.cs" /> … … 53 54 <Compile Include="DTO\PwgSession.cs" /> 54 55 <Compile Include="Properties\AssemblyInfo.cs" /> 56 <Compile Include="Proxy\PwgCategoriesProxy.cs" /> 55 57 <Compile Include="Proxy\Helper\PwgProxyReponseHelper.cs" /> 56 58 <Compile Include="Proxy\PwgTagsProxy.cs" /> 59 <Compile Include="Proxy\Response\PwgAddRequestProxyResponse.cs" /> 57 60 <Compile Include="Proxy\Response\PwgCategoriesProxyResponse.cs" /> 58 61 <Compile Include="Proxy\Response\PwgImagesProxyResponse.cs" /> … … 65 68 <Compile Include="Proxy\PwgProxyException.cs" /> 66 69 <Compile Include="Proxy\PwgSessionProxy.cs" /> 70 <Compile Include="Service\PwgCategoriesService.cs" /> 67 71 <Compile Include="Service\PwgImagesService.cs" /> 68 72 <Compile Include="Service\PwgTagsService.cs" /> -
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")] -
extensions/PiwigoLib/PiwigoLib/Service/PwgCategoriesService.cs
r3833 r3834 11 11 { 12 12 13 static public class Pwg TagsService13 static public class PwgCategoriesService 14 14 { 15 15 /// <summary> 16 /// Get the list of tagsthe user is connected can access16 /// Get the list of category the user is connected can access 17 17 /// </summary> 18 18 /// <param name="sortedByCounter"></param> 19 19 /// <returns></returns> 20 static public List<Pwg Tag> GetListOfTag(Boolean sortedByCounter)21 { 22 List<Pwg Tag> returnValue = new List<PwgTag>();23 24 try 25 { 26 Pwg TagsProxyResponse response = PwgTagsProxy.pwg_tags_getList(sortedByCounter);20 static public List<PwgCategory> GetListOfCategory(Int32? CatgeroryId, Boolean? Recursive, Boolean? PublicOnly) 21 { 22 List<PwgCategory> returnValue = new List<PwgCategory>(); 23 24 try 25 { 26 PwgCategoriesProxyResponse response = PwgCategoriesProxy.pwg_categories_getList(CatgeroryId, Recursive, PublicOnly); 27 27 28 28 if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok) … … 30 30 if (response.Erreur != null) 31 31 { 32 throw new PwgServiceException("GetListOf PwgTag, the server has return the error.",32 throw new PwgServiceException("GetListOfCategory, the server has return the error.", 33 33 response.Erreur.Code, 34 34 response.Erreur.Message); … … 36 36 else 37 37 { 38 throw new PwgServiceException("GetListOf PwgTag: a error occurs during server process.");38 throw new PwgServiceException("GetListOfCategory : a error occurs during server process."); 39 39 } 40 40 } … … 46 46 catch (PwgProxyException ex) 47 47 { 48 throw new PwgServiceException("GetListOfPwgTag : a error is raised by proxy.", ex); 49 } 50 return returnValue; 51 } 52 53 /// <summary> 54 /// Get the list of all atgs in piwigo, you must be connected with a high level user 55 /// </summary> 56 /// <param name="sortedByCounter"></param> 48 throw new PwgServiceException("GetListOfCategory : a error is raised by proxy.", ex); 49 } 50 return returnValue; 51 } 52 53 /// <summary> 54 /// Get List of all Category, must be logged as admin 55 /// </summary> 57 56 /// <returns></returns> 58 static public List<Pwg Tag> GetAdminListOfTag()59 { 60 List<Pwg Tag> returnValue = new List<PwgTag>();61 62 try 63 { 64 Pwg TagsProxyResponse response = PwgTagsProxy.pwg_tags_getAdminList();57 static public List<PwgCategory> GetAdminListOfCategory() 58 { 59 List<PwgCategory> returnValue = new List<PwgCategory>(); 60 61 try 62 { 63 PwgCategoriesProxyResponse response = PwgCategoriesProxy.pwg_categories_getAdminList(); 65 64 66 65 if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok) … … 68 67 if (response.Erreur != null) 69 68 { 70 throw new PwgServiceException("GetAdminListOf Tag, the server has return the error.",69 throw new PwgServiceException("GetAdminListOfCategory, the server has return the error.", 71 70 response.Erreur.Code, 72 71 response.Erreur.Message); … … 74 73 else 75 74 { 76 throw new PwgServiceException("GetAdminListOf Tag: a error occurs during server process.");75 throw new PwgServiceException("GetAdminListOfCategory : a error occurs during server process."); 77 76 } 78 77 } … … 84 83 catch (PwgProxyException ex) 85 84 { 86 throw new PwgServiceException("GetAdminListOf Tag: a error is raised by proxy.", ex);87 } 88 return returnValue; 89 } 90 91 /// <summary> 92 /// Add a Tag85 throw new PwgServiceException("GetAdminListOfCategory : a error is raised by proxy.", ex); 86 } 87 return returnValue; 88 } 89 90 /// <summary> 91 /// Add a Categorie 93 92 /// </summary> 94 93 /// <param name="tagName"></param> 95 94 /// <returns></returns> 96 static public Boolean Add Tag(String tagName)95 static public Boolean AddCategory(String categoryName, Int32? upperCatId, ref Int32 newId, ref String messageInfo) 97 96 { 98 97 Boolean returnValue = false; … … 100 99 try 101 100 { 102 Pwg TagsProxyResponse response = PwgTagsProxy.pwg_tag_add(tagName);101 PwgAddRequestProxyResponse response = PwgCategoriesProxy.pwg_categories_add(categoryName, upperCatId); 103 102 104 103 if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok) … … 118 117 { 119 118 returnValue = true; 119 newId = response.NewId; 120 messageInfo = response.Message; 120 121 } 121 122 } … … 126 127 return returnValue; 127 128 } 128 129 /// <summary>130 /// Return the list of image form a list of tag131 /// </summary>132 /// <param name="tagsId"></param>133 /// <param name="tagsUrlName"></param>134 /// <param name="tagsName"></param>135 /// <param name="tagModeAnd"></param>136 /// <param name="perPage"></param>137 /// <param name="Page"></param>138 /// <param name="Order"></param>139 /// <param name="minRate"></param>140 /// <param name="maxRate"></param>141 /// <param name="minHit"></param>142 /// <param name="maxHit"></param>143 /// <param name="minDateAvailable"></param>144 /// <param name="maxDateAvailable"></param>145 /// <param name="minDateCreated"></param>146 /// <param name="maxDateCreated"></param>147 /// <param name="minRatio"></param>148 /// <param name="maxRatio"></param>149 /// <param name="withThumbnail"></param>150 /// <param name="PageReturned"></param>151 /// <param name="PerPageeReturned"></param>152 /// <param name="CountReturned"></param>153 /// <returns></returns>154 static public List<PwgImage> GetListOfImagesFormTags(List<Int32> tagsId,155 List<String> tagsUrlName,156 List<String> tagsName,157 Boolean? tagModeAnd,158 Int32? perPage,159 Int32? Page,160 Int32? Order,161 Int32? minRate,162 Int32? maxRate,163 Int32? minHit,164 Int32? maxHit,165 DateTime? minDateAvailable,166 DateTime? maxDateAvailable,167 DateTime? minDateCreated,168 DateTime? maxDateCreated,169 Int32? minRatio,170 Int32? maxRatio,171 Boolean? withThumbnail,172 ref Int32 PageReturned,173 ref Int32 PerPageeReturned,174 ref Int32 CountReturned)175 {176 List<PwgImage> returnValue = new List<PwgImage>();177 178 try179 {180 PwgImagesProxyResponse response = PwgTagsProxy.pwg_tags_getImages(tagsId,181 tagsUrlName,182 tagsName,183 tagModeAnd,184 perPage,185 Page,186 Order,187 minRate,188 maxRate,189 minHit,190 maxHit,191 minDateAvailable,192 maxDateAvailable,193 minDateCreated,194 maxDateCreated,195 minRatio,196 maxRatio,197 withThumbnail);198 199 if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok)200 {201 if (response.Erreur != null)202 {203 throw new PwgServiceException("GetListOfImagesFormTags, the server has return the error.",204 response.Erreur.Code,205 response.Erreur.Message);206 }207 else208 {209 throw new PwgServiceException("GetListOfImagesFormTags : a error occurs during server process.");210 }211 }212 else213 {214 PwgImagesService.ConvertProxyResponseToDTO(response, returnValue,215 ref PageReturned,216 ref PerPageeReturned,217 ref CountReturned);218 }219 }220 catch (PwgProxyException ex)221 {222 throw new PwgServiceException("GetListOfImagesFormTags : a error is raised by proxy.", ex);223 }224 return returnValue;225 }226 227 129 228 130 /// <summary> … … 231 133 /// <param name="response"></param> 232 134 /// <param name="session"></param> 233 static public List<Pwg Tag> ConvertProxyResponseToDTO(PwgTagsProxyResponse response)234 { 235 List<Pwg Tag> returnValue = new List<PwgTag>();236 237 foreach (Pwg TagProxyResponse respTag in response.Tags)238 { 239 returnValue.Add(ConvertProxyResponseToDTO(resp Tag));135 static public List<PwgCategory> ConvertProxyResponseToDTO(PwgCategoriesProxyResponse response) 136 { 137 List<PwgCategory> returnValue = new List<PwgCategory>(); 138 139 foreach (PwgCategoryProxyResponse respCat in response.Categories) 140 { 141 returnValue.Add(ConvertProxyResponseToDTO(respCat)); 240 142 } 241 143 … … 249 151 /// <param name="response"></param> 250 152 /// <param name="session"></param> 251 static public PwgTag ConvertProxyResponseToDTO(PwgTagProxyResponse response) 252 { 253 PwgTag returnValue = new PwgTag(); 254 255 try 256 { 257 returnValue.Counter = response.Counter; 153 static public PwgCategory ConvertProxyResponseToDTO(PwgCategoryProxyResponse response) 154 { 155 PwgCategory returnValue = new PwgCategory(); 156 157 try 158 { 258 159 returnValue.Id = response.Id; 259 160 returnValue.Name = response.Name; 260 returnValue.UrlName = response.UrlName; 261 262 if (String.IsNullOrEmpty(response.UrlTag)) 263 { 264 returnValue.UrlTag = null; 265 } 266 else 267 { 268 returnValue.UrlTag = (new UriBuilder(response.UrlTag)).Uri; 161 162 returnValue.DeepImagesCount = response.DeepImagesCount; 163 returnValue.ImagesCount = response.ImagesCount; 164 returnValue.SubCategoriesCount = response.SubCategoriesCount; 165 166 returnValue.UpperCategoriesId = new List<int>(); 167 if (response.UpperCategoryId != null) 168 { 169 foreach (String stringId in response.UpperCategoryId.Split(',')) 170 { 171 returnValue.UpperCategoriesId.Add(Int32.Parse(stringId)); 172 } 173 } 174 175 if (response.LastDate != null) 176 { 177 DateTime tryDate; 178 if (DateTime.TryParse(response.LastDate, out tryDate)) 179 { 180 returnValue.LastDate = tryDate; 181 } 182 } 183 184 if (String.IsNullOrEmpty(response.Url)) 185 { 186 returnValue.Url = null; 187 } 188 else 189 { 190 returnValue.Url = (new UriBuilder(response.Url)).Uri; 269 191 } 270 192 } -
extensions/PiwigoLib/PiwigoLib/Service/PwgTagsService.cs
r3828 r3834 18 18 /// <param name="sortedByCounter"></param> 19 19 /// <returns></returns> 20 static public List<PwgTag> GetListOfTag(Boolean sortedByCounter)20 static public List<PwgTag> GetListOfTag(Boolean? sortedByCounter) 21 21 { 22 22 List<PwgTag> returnValue = new List<PwgTag>(); … … 94 94 /// <param name="tagName"></param> 95 95 /// <returns></returns> 96 static public Boolean AddTag(String tagName )96 static public Boolean AddTag(String tagName, ref Int32 newId, ref String messageInfo) 97 97 { 98 98 Boolean returnValue = false; … … 100 100 try 101 101 { 102 Pwg TagsProxyResponse response = PwgTagsProxy.pwg_tag_add(tagName);102 PwgAddRequestProxyResponse response = PwgTagsProxy.pwg_tag_add(tagName); 103 103 104 104 if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok) … … 118 118 { 119 119 returnValue = true; 120 newId = response.NewId; 121 messageInfo = response.Message; 120 122 } 121 123 } -
extensions/PiwigoLib/TestPiwigoLib/Form1.cs
r3827 r3834 48 48 49 49 //List<PwgTag> lstTag = PwgTagsService.GetAdminListOfTag(); 50 Int32 Page = 0;51 Int32 PerPage = 0;52 Int32 Count = 0;53 50 54 List<PwgImage> lstImg = PwgTagsService.GetListOfImagesFormTags(new List<Int32>() { 1, 7 },55 null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,56 ref Page, ref PerPage, ref Count);51 //Int32 Page = 0; 52 //Int32 PerPage = 0; 53 //Int32 Count = 0; 57 54 58 Console.WriteLine("lstImg : Page " + Page.ToString() + " PerPage " + PerPage); 55 //List<PwgImage> lstImg = PwgTagsService.GetListOfImagesFormTags(new List<Int32>() { 1, 7 }, 56 // null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 57 // ref Page, ref PerPage, ref Count); 58 59 //Console.WriteLine("lstImg : Page " + Page.ToString() + " PerPage " + PerPage); 60 61 List<PwgCategory> lstCat = PwgCategoriesService.GetAdminListOfCategory(); 62 59 63 60 64 sess = PwgSessionService.Logout();
Note: See TracChangeset
for help on using the changeset viewer.