Changeset 3834


Ignore:
Timestamp:
Sep 7, 2009, 2:46:08 PM (15 years ago)
Author:
bayral
Message:

start with pwg.catgeroies.* support

Location:
extensions/PiwigoLib
Files:
6 edited
4 copied

Legend:

Unmodified
Added
Removed
  • extensions/PiwigoLib/PiwigoLib/DTO/PwgCategory.cs

    r3833 r3834  
    77{
    88
    9     public class PwgTag
     9    public class PwgCategory
    1010    {
    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; }
    1619    }
    1720}
  • extensions/PiwigoLib/PiwigoLib/PiwigoLib.csproj

    r3827 r3834  
    44    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    55    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    6     <ProductVersion>9.0.21022</ProductVersion>
     6    <ProductVersion>9.0.30729</ProductVersion>
    77    <SchemaVersion>2.0</SchemaVersion>
    88    <ProjectGuid>{64C068C5-DBFE-4712-9081-B9100698F35C}</ProjectGuid>
     
    4747  </ItemGroup>
    4848  <ItemGroup>
     49    <Compile Include="DTO\PwgCategory.cs" />
    4950    <Compile Include="DTO\PwgImage.cs" />
    5051    <Compile Include="DTO\Helper\PwgEnumHelper.cs" />
     
    5354    <Compile Include="DTO\PwgSession.cs" />
    5455    <Compile Include="Properties\AssemblyInfo.cs" />
     56    <Compile Include="Proxy\PwgCategoriesProxy.cs" />
    5557    <Compile Include="Proxy\Helper\PwgProxyReponseHelper.cs" />
    5658    <Compile Include="Proxy\PwgTagsProxy.cs" />
     59    <Compile Include="Proxy\Response\PwgAddRequestProxyResponse.cs" />
    5760    <Compile Include="Proxy\Response\PwgCategoriesProxyResponse.cs" />
    5861    <Compile Include="Proxy\Response\PwgImagesProxyResponse.cs" />
     
    6568    <Compile Include="Proxy\PwgProxyException.cs" />
    6669    <Compile Include="Proxy\PwgSessionProxy.cs" />
     70    <Compile Include="Service\PwgCategoriesService.cs" />
    6771    <Compile Include="Service\PwgImagesService.cs" />
    6872    <Compile Include="Service\PwgTagsService.cs" />
  • extensions/PiwigoLib/PiwigoLib/Proxy/Helper/PwgProxyReponseHelper.cs

    r3827 r3834  
    77namespace Com.Piwigo.Lib.Proxy.Helper
    88{
    9     public static class PwgProxyReponseHelper<T>
     9    public static class PwgProxyReponseHelper
    1010    {
    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)
    1212        {
    1313            String FormatString = String.Empty;
     
    3434
    3535            }
     36        }
    3637
     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            }
    3761        }
    3862    }
  • extensions/PiwigoLib/PiwigoLib/Proxy/PwgCategoriesProxy.cs

    r3833 r3834  
    1010namespace Com.Piwigo.Lib.Proxy
    1111{
    12     static class PwgTagsProxy
     12    static class PwgCategoriesProxy
    1313    {
    14         static public PwgTagsProxyResponse pwg_tags_getList(Boolean sortedByCounter)
     14        static public PwgCategoriesProxyResponse pwg_categories_getList(Int32? CategoryId,
     15            Boolean? Recursive, Boolean? PublicOnly)
    1516        {
    16             PwgTagsProxyResponse response = null;
     17            PwgCategoriesProxyResponse response = null;
    1718            try
    1819            {
    1920                StringBuilder data = new StringBuilder();
    20                 data.Append("sort_by_counter=" + HttpUtility.UrlEncode(sortedByCounter.ToString().ToLower()));
     21                Boolean firstOcc = true;
    2122
    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(
    2328                                PwgConfigProxy.PwgServeurUriBuilder.Uri,
    24                                 "pwg.tags.getList", data.ToString());
     29                                "pwg.categories.getList", data.ToString());
    2530            }
    2631            catch (Exception ex)
    2732            {
    28                 throw new PwgProxyException("pwg_tags_getList", ex);
     33                throw new PwgProxyException("pwg_categories_getList", ex);
    2934            }
    3035            return response;
     
    3237        }
    3338
    34         static public PwgTagsProxyResponse pwg_tags_getAdminList()
     39        static public PwgCategoriesProxyResponse pwg_categories_getAdminList()
    3540        {
    36             PwgTagsProxyResponse response = null;
     41            PwgCategoriesProxyResponse response = null;
    3742            try
    3843            {
    39                 response = PwgGenericProxy<PwgTagsProxyResponse>.Get(
     44                response = PwgGenericProxy<PwgCategoriesProxyResponse>.Get(
    4045                                PwgConfigProxy.PwgServeurUriBuilder.Uri,
    41                                 "pwg.tags.getAdminList", null);
     46                                "pwg.categories.getAdminList", null);
    4247            }
    4348            catch (Exception ex)
    4449            {
    45                 throw new PwgProxyException("pwg_tags_getAdminList", ex);
     50                throw new PwgProxyException("pwg_categories_getAdminList", ex);
    4651            }
    4752            return response;
     
    4954        }
    5055
    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)
    6957        {
    70             PwgImagesProxyResponse response = null;
     58            PwgAddRequestProxyResponse response = null;
    7159            try
    7260            {
    7361                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);
    8066
    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(
    16368                    PwgConfigProxy.PwgServeurUriBuilder.Uri,
    16469                    data.ToString());
     
    16671            catch (Exception ex)
    16772            {
    168                 throw new PwgProxyException("pwg_tag_add", ex);
     73                throw new PwgProxyException("pwg_categories_add", ex);
    16974            }
    17075
     
    17277        }
    17378
     79
    17480    }
    17581
  • extensions/PiwigoLib/PiwigoLib/Proxy/PwgTagsProxy.cs

    r3827 r3834  
    1212    static class PwgTagsProxy
    1313    {
    14         static public PwgTagsProxyResponse pwg_tags_getList(Boolean sortedByCounter)
     14        static public PwgTagsProxyResponse pwg_tags_getList(Boolean? sortedByCounter)
    1515        {
    1616            PwgTagsProxyResponse response = null;
     
    1818            {
    1919                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);
    2123
    2224                response = PwgGenericProxy<PwgTagsProxyResponse>.Get(
     
    5557                                                                    Int32?           perPage,
    5658                                                                    Int32?           Page,
    57                                                                     Int32?          Order,
     59                                                                    Int32?           Order,
    5860                                                                    Int32?           minRate,
    5961                                                                    Int32?           maxRate,
     
    7577                data.AppendFormat("method={0}","pwg.tags.getImages");
    7678                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);
    8082
    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);
    14198
    14299                response = PwgGenericProxy<PwgImagesProxyResponse>.Post(
     
    151108
    152109        }
    153         static public PwgTagsProxyResponse pwg_tag_add(string tagName)
     110        static public PwgAddRequestProxyResponse pwg_tag_add(string tagName)
    154111        {
    155             PwgTagsProxyResponse response = null;
     112            PwgAddRequestProxyResponse response = null;
    156113            try
    157114            {
     
    160117                data.Append("&name=" + HttpUtility.UrlEncode(tagName));
    161118
    162                 response = PwgGenericProxy<PwgTagsProxyResponse>.Post(
     119                response = PwgGenericProxy<PwgAddRequestProxyResponse>.Post(
    163120                    PwgConfigProxy.PwgServeurUriBuilder.Uri,
    164121                    data.ToString());
  • extensions/PiwigoLib/PiwigoLib/Proxy/Response/PwgAddRequestProxyResponse.cs

    r3833 r3834  
    99{
    1010    [Serializable()]
    11     [XmlRoot(ElementName = "tag")]
    12     public class PwgTagProxyResponse
     11    [XmlRoot(ElementName = "rsp")]
     12    public class PwgAddRequestProxyResponse : PwgBaseProxyReponse
    1313    {
    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; }
    2518
    26     [Serializable()]
    27     [XmlRoot(ElementName = "rsp")]
    28     public class PwgTagsProxyResponse : PwgBaseProxyReponse
    29     {
    30         //[XmlElement(ElementName = "tags")]
    31         [XmlArray("tags")]
    32         [XmlArrayItem("tag")]
    33         public PwgTagProxyResponse[] Tags { get; set; }
    3419    }
    3520}
  • extensions/PiwigoLib/PiwigoLib/Proxy/Response/PwgCategoriesProxyResponse.cs

    r3827 r3834  
    99{
    1010    [Serializable()]
    11     [XmlRoot(ElementName = "categories")]
     11    [XmlRoot(ElementName = "category")]
    1212    public class PwgCategoryProxyResponse
    1313    {
    1414        [XmlAttribute(AttributeName = "id")]
    1515        public Int32 Id { get; set; }
    16         [XmlAttribute(AttributeName = "name")]
     16        [XmlElement(ElementName = "uppercats")]
     17        public String UpperCategoryId { get; set; }
     18        [XmlElement (ElementName = "name")]
    1719        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; }
    2220        [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; }
    2430    }
    2531
    2632    [Serializable()]
    2733    [XmlRoot(ElementName = "rsp")]
    28     public class PwgcategoriesProxyResponse : PwgBaseProxyReponse
     34    public class PwgCategoriesProxyResponse : PwgBaseProxyReponse
    2935    {
    3036        [XmlArray("categories")]
  • extensions/PiwigoLib/PiwigoLib/Service/PwgCategoriesService.cs

    r3833 r3834  
    1111{
    1212
    13     static public class PwgTagsService
     13    static public class PwgCategoriesService
    1414    {
    1515        /// <summary>
    16         /// Get the list of tags the user is connected can access
     16        /// Get the list of category the user is connected can access
    1717        /// </summary>
    1818        /// <param name="sortedByCounter"></param>
    1919        /// <returns></returns>
    20         static public List<PwgTag> GetListOfTag(Boolean sortedByCounter)
    21         {
    22             List<PwgTag> returnValue = new List<PwgTag>();
    23 
    24             try
    25             {
    26                 PwgTagsProxyResponse 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);
    2727
    2828                if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok)
     
    3030                    if (response.Erreur != null)
    3131                    {
    32                         throw new PwgServiceException("GetListOfPwgTag, the server has return the error.",
     32                        throw new PwgServiceException("GetListOfCategory, the server has return the error.",
    3333                            response.Erreur.Code,
    3434                            response.Erreur.Message);
     
    3636                    else
    3737                    {
    38                         throw new PwgServiceException("GetListOfPwgTag : a error occurs during server process.");
     38                        throw new PwgServiceException("GetListOfCategory : a error occurs during server process.");
    3939                    }
    4040                }
     
    4646            catch (PwgProxyException ex)
    4747            {
    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>
    5756        /// <returns></returns>
    58         static public List<PwgTag> GetAdminListOfTag()
    59         {
    60             List<PwgTag> returnValue = new List<PwgTag>();
    61 
    62             try
    63             {
    64                 PwgTagsProxyResponse 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();
    6564
    6665                if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok)
     
    6867                    if (response.Erreur != null)
    6968                    {
    70                         throw new PwgServiceException("GetAdminListOfTag, the server has return the error.",
     69                        throw new PwgServiceException("GetAdminListOfCategory, the server has return the error.",
    7170                            response.Erreur.Code,
    7271                            response.Erreur.Message);
     
    7473                    else
    7574                    {
    76                         throw new PwgServiceException("GetAdminListOfTag : a error occurs during server process.");
     75                        throw new PwgServiceException("GetAdminListOfCategory : a error occurs during server process.");
    7776                    }
    7877                }
     
    8483            catch (PwgProxyException ex)
    8584            {
    86                 throw new PwgServiceException("GetAdminListOfTag : a error is raised by proxy.", ex);
    87             }
    88             return returnValue;
    89         }
    90 
    91         /// <summary>
    92         /// Add a Tag
     85                throw new PwgServiceException("GetAdminListOfCategory : a error is raised by proxy.", ex);
     86            }
     87            return returnValue;
     88        }
     89
     90        /// <summary>
     91        /// Add a Categorie
    9392        /// </summary>
    9493        /// <param name="tagName"></param>
    9594        /// <returns></returns>
    96         static public Boolean AddTag(String tagName)
     95        static public Boolean AddCategory(String categoryName, Int32? upperCatId, ref Int32 newId, ref String messageInfo)
    9796        {
    9897            Boolean returnValue = false;
     
    10099            try
    101100            {
    102                 PwgTagsProxyResponse response = PwgTagsProxy.pwg_tag_add(tagName);
     101                PwgAddRequestProxyResponse response = PwgCategoriesProxy.pwg_categories_add(categoryName, upperCatId);
    103102
    104103                if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok)
     
    118117                {
    119118                    returnValue = true;
     119                    newId = response.NewId;
     120                    messageInfo = response.Message;
    120121                }
    121122            }
     
    126127            return returnValue;
    127128        }
    128 
    129         /// <summary>
    130         /// Return the list of image form a list of tag
    131         /// </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             try
    179             {
    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                     else
    208                     {
    209                         throw new PwgServiceException("GetListOfImagesFormTags : a error occurs during server process.");
    210                     }
    211                 }
    212                 else
    213                 {
    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 
    227129
    228130        /// <summary>
     
    231133        /// <param name="response"></param>
    232134        /// <param name="session"></param>
    233         static public List<PwgTag> ConvertProxyResponseToDTO(PwgTagsProxyResponse response)
    234         {
    235             List<PwgTag> returnValue = new List<PwgTag>();
    236 
    237             foreach (PwgTagProxyResponse respTag in response.Tags)
    238             {
    239                 returnValue.Add(ConvertProxyResponseToDTO(respTag));
     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));
    240142            }
    241143
     
    249151        /// <param name="response"></param>
    250152        /// <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            {
    258159                returnValue.Id = response.Id;
    259160                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;
    269191                }
    270192            }
  • extensions/PiwigoLib/PiwigoLib/Service/PwgTagsService.cs

    r3828 r3834  
    1818        /// <param name="sortedByCounter"></param>
    1919        /// <returns></returns>
    20         static public List<PwgTag> GetListOfTag(Boolean sortedByCounter)
     20        static public List<PwgTag> GetListOfTag(Boolean? sortedByCounter)
    2121        {
    2222            List<PwgTag> returnValue = new List<PwgTag>();
     
    9494        /// <param name="tagName"></param>
    9595        /// <returns></returns>
    96         static public Boolean AddTag(String tagName)
     96        static public Boolean AddTag(String tagName, ref Int32 newId, ref String messageInfo)
    9797        {
    9898            Boolean returnValue = false;
     
    100100            try
    101101            {
    102                 PwgTagsProxyResponse response = PwgTagsProxy.pwg_tag_add(tagName);
     102                PwgAddRequestProxyResponse response = PwgTagsProxy.pwg_tag_add(tagName);
    103103
    104104                if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok)
     
    118118                {
    119119                    returnValue = true;
     120                    newId = response.NewId;
     121                    messageInfo = response.Message;
    120122                }
    121123            }
  • extensions/PiwigoLib/TestPiwigoLib/Form1.cs

    r3827 r3834  
    4848
    4949                //List<PwgTag> lstTag = PwgTagsService.GetAdminListOfTag();
    50                 Int32 Page = 0;
    51                 Int32 PerPage = 0;
    52                 Int32 Count = 0;
    5350
    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;
    5754
    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
    5963
    6064                sess = PwgSessionService.Logout();
Note: See TracChangeset for help on using the changeset viewer.