source: extensions/PiwigoLib/PiwigoLib/Proxy/PwgCategoriesProxy.cs @ 7149

Last change on this file since 7149 was 7149, checked in by bayral, 14 years ago

Piwigolib is now modify for mask the implementation of proxy.
Add start version of piwigo WPF

File size: 10.2 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 PwgCategoriesProxy
13    {
14        /// <summary>
15        /// pwg.categories.getList
16        /// </summary>
17        /// <param name="CategoryId"></param>
18        /// <param name="Recursive"></param>
19        /// <param name="PublicOnly"></param>
20        /// <returns></returns>
21        static internal PwgCategoriesProxyResponse pwg_categories_getList(Int32? CategoryId, 
22            Boolean? Recursive, Boolean? PublicOnly)
23        {
24            PwgCategoriesProxyResponse response = null;
25            try
26            {
27                StringBuilder data = new StringBuilder();
28                Boolean firstOcc = true;
29
30                PwgProxyReponseHelper.buildQueryFromValue<Int32>(CategoryId, "cat_id", ref firstOcc, data);
31                PwgProxyReponseHelper.buildQueryFromValue<Boolean>(Recursive, "recursive", ref firstOcc, data);
32                PwgProxyReponseHelper.buildQueryFromValue<Boolean>(PublicOnly, "public", ref firstOcc, data);
33
34                response = PwgGenericProxy<PwgCategoriesProxyResponse>.Get(
35                                PwgConfigProxy.PwgServeurUri,
36                                "pwg.categories.getList", data.ToString());
37            }
38            catch (Exception ex)
39            {
40                throw new PwgProxyException("pwg_categories_getList", ex);
41            }
42            return response;
43
44        }
45
46        /// <summary>
47        /// pwg.categories.getAdminList
48        /// </summary>
49        /// <returns></returns>
50        static internal PwgCategoriesProxyResponse pwg_categories_getAdminList()
51        {
52            PwgCategoriesProxyResponse response = null;
53            try
54            {
55                response = PwgGenericProxy<PwgCategoriesProxyResponse>.Get(
56                                PwgConfigProxy.PwgServeurUri,
57                                "pwg.categories.getAdminList", null);
58            }
59            catch (Exception ex)
60            {
61                throw new PwgProxyException("pwg_categories_getAdminList", ex);
62            }
63            return response;
64
65        }
66
67        /// <summary>
68        /// pwg.categories.add
69        /// </summary>
70        /// <param name="categorieName"></param>
71        /// <param name="IdUpperCat"></param>
72        /// <returns></returns>
73        static internal PwgAddRequestProxyResponse pwg_categories_add(String categorieName, Int32? IdUpperCat)
74        {
75            PwgAddRequestProxyResponse response = null;
76            try
77            {
78                StringBuilder data = new StringBuilder();
79                data.Append("method=pwg.categories.add");
80                Boolean firstOcc = false;
81                PwgProxyReponseHelper.buildQueryFromValue<String>(categorieName, "name", ref firstOcc, data);
82                PwgProxyReponseHelper.buildQueryFromValue<Int32>(IdUpperCat, "parent", ref firstOcc, data);
83
84                response = PwgGenericProxy<PwgAddRequestProxyResponse>.Post(
85                    PwgConfigProxy.PwgServeurUri,
86                    data.ToString());
87            }
88            catch (Exception ex)
89            {
90                throw new PwgProxyException("pwg_categories_add", ex);
91            }
92
93            return response;
94        }
95
96        /// <summary>
97        /// pwg.categories.setInfo
98        /// </summary>
99        /// <param name="IdCat"></param>
100        /// <param name="categorieName"></param>
101        /// <param name="categorieComment"></param>
102        /// <returns></returns>
103        static internal PwgBaseProxyReponse pwg_categories_setInfo(Int32 IdCat, String categorieName, String categorieComment)
104        {
105            PwgBaseProxyReponse response = null;
106            try
107            {
108                StringBuilder data = new StringBuilder();
109                data.Append("method=pwg.categories.setInfo");
110                Boolean firstOcc = false;
111                PwgProxyReponseHelper.buildQueryFromValue<Int32>(IdCat, "category_id", ref firstOcc, data);
112                PwgProxyReponseHelper.buildQueryFromValue<String>(categorieName, "name", ref firstOcc, data);
113                PwgProxyReponseHelper.buildQueryFromValue<String>(categorieComment, "comment", ref firstOcc, data);
114
115                response = PwgGenericProxy<PwgAddRequestProxyResponse>.Post(
116                    PwgConfigProxy.PwgServeurUri,
117                    data.ToString());
118            }
119            catch (Exception ex)
120            {
121                throw new PwgProxyException("pwg_categories_setInfo", ex);
122            }
123
124            return response;
125        }
126
127        /// <summary>
128        /// pwg.categories.getImages
129        /// </summary>
130        /// <param name="catId"></param>
131        /// <param name="recursive"></param>
132        /// <param name="perPage"></param>
133        /// <param name="Page"></param>
134        /// <param name="Order"></param>
135        /// <param name="minRate"></param>
136        /// <param name="maxRate"></param>
137        /// <param name="minHit"></param>
138        /// <param name="maxHit"></param>
139        /// <param name="minDateAvailable"></param>
140        /// <param name="maxDateAvailable"></param>
141        /// <param name="minDateCreated"></param>
142        /// <param name="maxDateCreated"></param>
143        /// <param name="minRatio"></param>
144        /// <param name="maxRatio"></param>
145        /// <param name="withThumbnail"></param>
146        /// <returns></returns>
147        static internal PwgImagesProxyResponse pwg_categories_getImages(Int32 catId,
148                                                            Boolean? recursive,
149                                                            Int32? perPage,
150                                                            Int32? Page,
151                                                            Int32? Order,
152                                                            Int32? minRate,
153                                                            Int32? maxRate,
154                                                            Int32? minHit,
155                                                            Int32? maxHit,
156                                                            DateTime? minDateAvailable,
157                                                            DateTime? maxDateAvailable,
158                                                            DateTime? minDateCreated,
159                                                            DateTime? maxDateCreated,
160                                                            Int32? minRatio,
161                                                            Int32? maxRatio,
162                                                            Boolean? withThumbnail)
163        {
164            PwgImagesProxyResponse response = null;
165            try
166            {
167                StringBuilder data = new StringBuilder();
168                Boolean firstOcc = true;
169                data.AppendFormat("method={0}", "pwg.categories.getImages");
170                firstOcc = false;
171                PwgProxyReponseHelper.buildQueryFromValue<Int32>(catId, "cat_id", ref firstOcc, data);
172
173                PwgProxyReponseHelper.buildQueryFromValue<Boolean>(recursive, "recursive", ref firstOcc, data);
174                PwgProxyReponseHelper.buildQueryFromValue<Int32>(perPage, "per_page", ref firstOcc, data);
175                PwgProxyReponseHelper.buildQueryFromValue<Int32>(Page, "page", ref firstOcc, data);
176                PwgProxyReponseHelper.buildQueryFromValue<Int32>(Order, "order", ref firstOcc, data);
177                PwgProxyReponseHelper.buildQueryFromValue<Int32>(minRate, "f_min_rate", ref firstOcc, data);
178                PwgProxyReponseHelper.buildQueryFromValue<Int32>(maxRate, "f_max_rate", ref firstOcc, data);
179                PwgProxyReponseHelper.buildQueryFromValue<Int32>(minHit, "f_min_hit", ref firstOcc, data);
180                PwgProxyReponseHelper.buildQueryFromValue<Int32>(maxHit, "f_max_hit", ref firstOcc, data);
181                PwgProxyReponseHelper.buildQueryFromValue<DateTime>(minDateAvailable, "f_min_date_available", ref firstOcc, data);
182                PwgProxyReponseHelper.buildQueryFromValue<DateTime>(maxDateAvailable, "f_max_date_available", ref firstOcc, data);
183                PwgProxyReponseHelper.buildQueryFromValue<DateTime>(minDateCreated, "f_min_date_created", ref firstOcc, data);
184                PwgProxyReponseHelper.buildQueryFromValue<DateTime>(maxDateCreated, "f_max_date_created", ref firstOcc, data);
185                PwgProxyReponseHelper.buildQueryFromValue<Int32>(minRatio, "f_min_ratio", ref firstOcc, data);
186                PwgProxyReponseHelper.buildQueryFromValue<Int32>(maxRatio, "f_max_ratio", ref firstOcc, data);
187                PwgProxyReponseHelper.buildQueryFromValue<Boolean>(withThumbnail, "f_with_thumbnail", ref firstOcc, data);
188
189                response = PwgGenericProxy<PwgImagesProxyResponse>.Post(
190                                PwgConfigProxy.PwgServeurUri,
191                                data.ToString());
192            }
193            catch (Exception ex)
194            {
195                throw new PwgProxyException("pwg_categories_getImages", ex);
196            }
197            return response;
198
199        }
200
201        /// <summary>
202        ///
203        /// </summary>
204        /// <param name="tagName"></param>
205        /// <returns></returns>
206        static internal PwgAddRequestProxyResponse pwg_tag_add(string tagName)
207        {
208            PwgAddRequestProxyResponse response = null;
209            try
210            {
211                StringBuilder data = new StringBuilder();
212                data.Append("method=pwg.tags.add");
213                data.Append("&name=" + HttpUtility.UrlEncode(tagName));
214
215                response = PwgGenericProxy<PwgAddRequestProxyResponse>.Post(
216                    PwgConfigProxy.PwgServeurUri,
217                    data.ToString());
218            }
219            catch (Exception ex)
220            {
221                throw new PwgProxyException("pwg_tag_add", ex);
222            }
223
224            return response;
225        }
226
227    }
228
229}
230
Note: See TracBrowser for help on using the repository browser.