source: extensions/PiwigoLib/PiwigoLib/Proxy/PwgTagsProxy.cs @ 12035

Last change on this file since 12035 was 12035, checked in by bayral, 13 years ago

changing dot.net framework prerequisite from framework 4.0 to framework 4.0 client profile according to setup process download

File size: 7.0 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5using Com.Piwigo.Lib.DTO;
6using System.Web;
7using Com.Piwigo.Lib.Proxy.Response;
8using Com.Piwigo.Lib.Proxy.Helper;
9
10namespace Com.Piwigo.Lib.Proxy
11{
12    static internal class PwgTagsProxy
13    {
14        /* pwg.tags.add             pwg_tag_add
15         * pwg.tags.getAdminList    pwg_tags_getAdminList
16         * pwg.tags.getImages       pwg_tags_getImages
17         * pwg.tags.getList         pwg_tags_getList
18         * */
19
20        static internal PwgTagsProxyResponse pwg_tags_getList(Boolean? sortedByCounter)
21        {
22            PwgTagsProxyResponse response = null;
23            try
24            {
25                StringBuilder data = new StringBuilder();
26                Boolean firstOcc = true;
27
28                PwgProxyReponseHelper.buildQueryFromValue<Boolean>(sortedByCounter, "sort_by_counter", ref firstOcc, data);
29
30                response = PwgGenericProxy<PwgTagsProxyResponse>.Get(
31                                PwgConfigProxy.PwgServeurUri,
32                                "pwg.tags.getList", data.ToString());
33            }
34            catch (Exception ex)
35            {
36                throw new PwgProxyException("pwg_tags_getList", ex);
37            }
38            return response;
39
40        }
41
42        static internal PwgTagsProxyResponse pwg_tags_getAdminList()
43        {
44            PwgTagsProxyResponse response = null;
45            try
46            {
47                response = PwgGenericProxy<PwgTagsProxyResponse>.Get(
48                                PwgConfigProxy.PwgServeurUri,
49                                "pwg.tags.getAdminList", null);
50            }
51            catch (Exception ex)
52            {
53                throw new PwgProxyException("pwg_tags_getAdminList", ex);
54            }
55            return response;
56
57        }
58
59        static internal PwgImagesProxyResponse pwg_tags_getImages(List<Int32> tagsId,           
60                                                                    List<String>    tagsUrlName,
61                                                                    List<String>    tagsName,
62                                                                    Boolean?         tagModeAnd,
63                                                                    Int32?           perPage,
64                                                                    Int32?           Page,
65                                                                    Int32?           Order,
66                                                                    Int32?           minRate,
67                                                                    Int32?           maxRate,
68                                                                    Int32?           minHit,
69                                                                    Int32?           maxHit,
70                                                                    DateTime?        minDateAvailable,
71                                                                    DateTime?        maxDateAvailable,
72                                                                    DateTime?        minDateCreated,
73                                                                    DateTime?        maxDateCreated,
74                                                                    Int32?           minRatio,
75                                                                    Int32?           maxRatio,
76                                                                    Boolean?         withThumbnail)
77        {
78            PwgImagesProxyResponse response = null;
79            try
80            {
81                StringBuilder data = new StringBuilder();
82                Boolean firstOcc = true;
83                data.AppendFormat("method={0}","pwg.tags.getImages");
84                firstOcc = false;
85                PwgProxyReponseHelper.buildQueryFromArray<Int32>(tagsId, "tag_id", ref firstOcc, data);
86                PwgProxyReponseHelper.buildQueryFromArray<String>(tagsUrlName, "tag_url_name", ref firstOcc, data);
87                PwgProxyReponseHelper.buildQueryFromArray<String>(tagsName, "tag_name", ref firstOcc, data);
88
89                PwgProxyReponseHelper.buildQueryFromValue<Boolean>(tagModeAnd, "tag_mode_and", ref firstOcc, data);
90                PwgProxyReponseHelper.buildQueryFromValue<Int32>(perPage, "per_page", ref firstOcc, data);
91                PwgProxyReponseHelper.buildQueryFromValue<Int32>(Page, "page", ref firstOcc, data);
92                PwgProxyReponseHelper.buildQueryFromValue<Int32>(Order, "order", ref firstOcc, data);
93                PwgProxyReponseHelper.buildQueryFromValue<Int32>(minRate, "f_min_rate", ref firstOcc, data);
94                PwgProxyReponseHelper.buildQueryFromValue<Int32>(maxRate, "f_max_rate", ref firstOcc, data);
95                PwgProxyReponseHelper.buildQueryFromValue<Int32>(minHit, "f_min_hit", ref firstOcc, data);
96                PwgProxyReponseHelper.buildQueryFromValue<Int32>(maxHit, "f_max_hit", ref firstOcc, data);
97                PwgProxyReponseHelper.buildQueryFromValue<DateTime>(minDateAvailable, "f_min_date_available", ref firstOcc, data);
98                PwgProxyReponseHelper.buildQueryFromValue<DateTime>(maxDateAvailable, "f_max_date_available", ref firstOcc, data);
99                PwgProxyReponseHelper.buildQueryFromValue<DateTime>(minDateCreated, "f_min_date_created", ref firstOcc, data);
100                PwgProxyReponseHelper.buildQueryFromValue<DateTime>(maxDateCreated, "f_max_date_created", ref firstOcc, data);
101                PwgProxyReponseHelper.buildQueryFromValue<Int32>(minRatio, "f_min_ratio", ref firstOcc, data);
102                PwgProxyReponseHelper.buildQueryFromValue<Int32>(maxRatio, "f_max_ratio", ref firstOcc, data);
103                PwgProxyReponseHelper.buildQueryFromValue<Boolean>(withThumbnail, "f_with_thumbnail", ref firstOcc, data);
104
105                response = PwgGenericProxy<PwgImagesProxyResponse>.Post(
106                                PwgConfigProxy.PwgServeurUri,
107                                data.ToString());
108            }
109            catch (Exception ex)
110            {
111                throw new PwgProxyException("pwg_tags_getImages", ex);
112            }
113            return response;
114
115        }
116        static internal PwgAddRequestProxyResponse pwg_tag_add(String tagName)
117        {
118            PwgAddRequestProxyResponse response = null;
119            try
120            {
121                StringBuilder data = new StringBuilder();
122                data.Append("method=pwg.tags.add");
123                data.Append("&name=" + Uri.EscapeUriString(tagName));
124
125                response = PwgGenericProxy<PwgAddRequestProxyResponse>.Post(
126                    PwgConfigProxy.PwgServeurUri,
127                    data.ToString());
128            }
129            catch (Exception ex)
130            {
131                throw new PwgProxyException("pwg_tag_add", ex);
132            }
133
134            return response;
135        }
136
137    }
138
139}
140
Note: See TracBrowser for help on using the repository browser.