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

start with pwg.catgeroies.* support

File:
1 copied

Legend:

Unmodified
Added
Removed
  • 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            }
Note: See TracChangeset for help on using the changeset viewer.