Changeset 3818 for extensions/PiwigoLib


Ignore:
Timestamp:
Sep 3, 2009, 4:03:22 PM (15 years ago)
Author:
bayral
Message:

get Tags List support

Location:
extensions/PiwigoLib
Files:
6 edited
2 copied

Legend:

Unmodified
Added
Removed
  • extensions/PiwigoLib/PiwigoLib/PiwigoLib.csproj

    r3816 r3818  
    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>
     
    5353    <Compile Include="Properties\AssemblyInfo.cs" />
    5454    <Compile Include="Proxy\PwgTagsProxy.cs" />
    55     <Compile Include="Proxy\Response\PwgTagsProxyResponse.cs" />
     55    <Compile Include="Proxy\Response\PwgSessionProxyResponse.cs" />
    5656    <Compile Include="Proxy\Response\PwgBaseProxyReponse.cs" />
    5757    <Compile Include="Proxy\Response\PwgBaseProxyReponseRetourEnum.cs" />
    58     <Compile Include="Proxy\Response\PwgSessionProxyResponse.cs" />
     58    <Compile Include="Proxy\Response\PwgTagsProxyResponse.cs" />
    5959    <Compile Include="Proxy\PwgConfigProxy.cs" />
    6060    <Compile Include="Proxy\PwgGenericProxy.cs" />
  • extensions/PiwigoLib/PiwigoLib/Proxy/PwgGenericProxy.cs

    r3816 r3818  
    1212{
    1313
    14     static class PwgGenericProxy<T>
     14    static public class PwgGenericProxy<T>
    1515    {
    1616       
  • extensions/PiwigoLib/PiwigoLib/Proxy/PwgTagsProxy.cs

    r3816 r3818  
    3030
    3131        }
     32
     33        static public PwgTagsProxyResponse pwg_tags_getAdminList()
     34        {
     35            PwgTagsProxyResponse response = null;
     36            try
     37            {
     38                response = PwgGenericProxy<PwgTagsProxyResponse>.Get(
     39                                PwgConfigProxy.PwgServeurUriBuilder.Uri,
     40                                "pwg.tags.getAdminList", null);
     41            }
     42            catch (Exception ex)
     43            {
     44                throw new PwgProxyException("pwg_tags_getAdminList", ex);
     45            }
     46            return response;
     47
     48        }
     49
    3250    }
    3351
  • extensions/PiwigoLib/PiwigoLib/Proxy/Response/PwgBaseProxyReponse.cs

    r3816 r3818  
    2727        public PwgBaseProxyReponseRetourEnum Retour { get; set; }
    2828
    29         [XmlElement( ElementName="err")]
     29        [XmlElement(ElementName="err")]
    3030        public PwgBaseProxyReponseError Erreur { get; set; }
    3131
  • extensions/PiwigoLib/PiwigoLib/Proxy/Response/PwgTagsProxyResponse.cs

    r3816 r3818  
    1212    public class PwgTagProxyResponse
    1313    {
    14         [XmlElement(ElementName = "id")]
     14        [XmlAttribute(AttributeName = "id")]
    1515        public Int16 Id { get; set; }
    16         [XmlElement(ElementName = "name")]
     16        [XmlAttribute(AttributeName = "name")]
    1717        public String Name { get; set; }
    18         [XmlElement(ElementName = "url_name")]
     18        [XmlAttribute(AttributeName = "url_name")]
    1919        public String UrlName { get; set; }
    20         [XmlElement(ElementName = "counter")]
     20        [XmlAttribute(AttributeName = "counter")]
    2121        public Int64 Counter { get; set; }
    22         [XmlElement(ElementName = "url")]
     22        [XmlAttribute(AttributeName = "url")]
    2323        public String UrlTag { get; set; }
    2424    }
     
    2828    public class PwgTagsProxyResponse : PwgBaseProxyReponse
    2929    {
    30         [XmlElement(ElementName = "tags")]
    31         public List<PwgTagProxyResponse> Tags { get; set; }
     30        //[XmlElement(ElementName = "tags")]
     31        [XmlArray("tags")]
     32        [XmlArrayItem("tag")]
     33        public PwgTagProxyResponse[] Tags { get; set; }
    3234    }
    3335}
  • extensions/PiwigoLib/PiwigoLib/Service/PwgTagsService.cs

    r3816 r3818  
    1010namespace Com.Piwigo.Lib.Service
    1111{
    12  
     12
    1313    static public class PwgTagsService
    1414    {
    15 
    16         static public List<PwgTag> GetListOfPwgTag(Boolean sortedByCounter)
     15        /// <summary>
     16        /// Get the list of tags the user is connected can access
     17        /// </summary>
     18        /// <param name="sortedByCounter"></param>
     19        /// <returns></returns>
     20        static public List<PwgTag> GetListOfTag(Boolean sortedByCounter)
    1721        {
    1822            List<PwgTag> returnValue = new List<PwgTag>();
     
    4852
    4953        /// <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>
     57        /// <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();
     65
     66                if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok)
     67                {
     68                    if (response.Erreur != null)
     69                    {
     70                        throw new PwgServiceException("GetAdminListOfTag, the server has return the error.",
     71                            response.Erreur.Code,
     72                            response.Erreur.Message);
     73                    }
     74                    else
     75                    {
     76                        throw new PwgServiceException("GetAdminListOfTag : a error occurs during server process.");
     77                    }
     78                }
     79                else
     80                {
     81                    returnValue = ConvertProxyResponseToDTO(response);
     82                }
     83            }
     84            catch (PwgProxyException ex)
     85            {
     86                throw new PwgServiceException("GetAdminListOfTag : a error is raised by proxy.", ex);
     87            }
     88            return returnValue;
     89        }
     90
     91
     92        /// <summary>
    5093        /// private: convert response to dto object
    5194        /// </summary>
     
    5699            List<PwgTag> returnValue = new List<PwgTag>();
    57100
     101            foreach (PwgTagProxyResponse respTag in response.Tags)
     102            {
     103                returnValue.Add(ConvertProxyResponseToDTO(respTag));
     104            }
     105
     106            return returnValue;
     107        }
     108
     109        /// <summary>
     110        /// private: convert response to dto object
     111        /// </summary>
     112        /// <param name="response"></param>
     113        /// <param name="session"></param>
     114        static private PwgTag ConvertProxyResponseToDTO(PwgTagProxyResponse response)
     115        {
     116            PwgTag returnValue = new PwgTag();
     117
     118            try
     119            {
     120                returnValue.Counter = response.Counter;
     121                returnValue.Id = response.Id;
     122                returnValue.Name = response.Name;
     123                returnValue.UrlName = response.UrlName;
     124
     125                if (String.IsNullOrEmpty(response.UrlTag))
     126                {
     127                    returnValue.UrlTag = null;
     128                }
     129                else
     130                {
     131                    returnValue.UrlTag = (new UriBuilder(response.UrlTag)).Uri;
     132                }
     133            }
     134            catch (Exception ex)
     135            {
     136                throw new PwgServiceException("ConvertProxyResponseToDTO : a error is raised when converting PwgTagProxyResponse.", ex);
     137            }
     138
    58139            return returnValue;
    59140        }
  • extensions/PiwigoLib/TestPiwigoLib/Form1.cs

    r3817 r3818  
    1111using Com.Piwigo.Lib.Service;
    1212using Com.Piwigo.Lib.DTO;
     13using Com.Piwigo.Lib.Proxy.Response;
    1314
    1415
     
    4041                Console.WriteLine("user : " + sess.UserName + " " + sess.Status);
    4142
    42                 List<PwgTag> lstTag = PwgTagsService.GetListOfPwgTag(false);
     43                List<PwgTag> lstTag = PwgTagsService.GetAdminListOfTag();
    4344
    4445                sess = PwgSessionService.Logout();
Note: See TracChangeset for help on using the changeset viewer.