Changeset 11872
- Timestamp:
- Aug 1, 2011, 5:47:03 PM (13 years ago)
- Location:
- extensions/PiwigoLib
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/PiwigoLib/PiwigoLib/DTO/PwgImage.cs
r11850 r11872 16 16 public Uri UrlHighDef { get; set; } 17 17 public Int64 Counter { get; set; } 18 public DateTime CreatingDate { get; set; } 19 public DateTime AvailableDate { get; set; } 18 20 19 21 public List<PwgTag> Tags { get; set; } 20 22 21 23 public List<PwgCategory> Categories { get; set; } 24 } 22 25 26 //<image 27 //tn_ext="jpg" author="bayral" filesize="62" date_metadata_update="2011-04-12" 28 //has_high="true" high_filesize="1667" level="0" md5sum="198c02a16d5f69c3def90908b33089c3" added_by="1" 29 //<name>P1120275</name> 30 //<rates count="0" average=""/> 31 //<comment_post author="bayral" key="1312204731.6:2:6f7f43b81bcf86540216c6f39b9122a6"/> 32 //<comments page="0" per_page="10" count="1" nb_comments="1"> 33 //<comment id="1" date="2011-08-01 13:37:59"> 34 // <author>bayral</author> 35 // <content>test[b] demod[/b]</content> 36 //</comment> 37 //</comments> 38 //</image> 39 public class PwgImageInfo : PwgImage 40 { 41 public String ExtThumbail { get; set; } 42 public String Author { get; set; } 43 public Int64 ImageFileSize { get; set; } 44 public DateTime DateupdateMetaData { get; set; } 45 public Boolean hasHighDef { get; set; } 46 public Int64 HighDefFileSize { get; set; } 47 public Int32 ConfidentialLevel { get; set; } 48 public String mdSum { get; set; } 49 public Int32 UserIdAddedBy { get; set; } 50 public String Name { get; set; } 51 52 public PwgImageRate ImageRate { get; set; } 53 public PwgCommentPage ImageComments { get; set; } 54 public PwgPostCommentSecurityInfo PostCommenSecurityData { get; set; } 55 } 56 57 public class PwgPostCommentSecurityInfo 58 { 59 public String Author { get; set; } 60 public String AllowPostKey { get; set; } 61 } 62 63 public class PwgCommentPage : List<PwgComment> 64 { 65 public Int32 Page { get; set; } 66 public Int32 PerPage { get; set; } 67 public Int32 CountOf { get; set; } 68 public Int32 TotalCommentNumber { get; set; } 69 } 70 71 public class PwgComment 72 { 73 public Int32 Id { get; set; } 74 public DateTime CommentDate { get; set; } 75 public String Author { get; set; } 76 public String Content { get; set; } 23 77 } 24 78 … … 26 80 { 27 81 public Int32 Count { get; set; } 28 public Double 82 public Double Average { get; set; } 29 83 public Double Stdev { get; set; } 30 84 } 85 86 public class PwgImageAdded 87 { 88 public Int32 Id { get; set; } 89 public Uri UrlElement { get; set; } 90 } 91 31 92 } -
extensions/PiwigoLib/PiwigoLib/IService/IPwgImagesService.cs
r11850 r11872 1 1 using System; 2 2 3 namespace Com.Piwigo.Lib.IService 3 4 { … … 5 6 { 6 7 Com.Piwigo.Lib.DTO.PwgImageRate RateImage(Int32 imageId, Int32 imageRate); 7 Boolean addImageByMultiPartForm(System.IO.FileInfo fileImage, Int32? imageId, Int32? categoryId, String imageName, String imageAuthor, String imageComment, Int32? imageLevel, String imageTags); 8 Com.Piwigo.Lib.DTO.PwgImageAdded addImageByMultiPartForm(System.IO.FileInfo fileImage, Int32? imageId, Int32? categoryId, String imageName, String imageAuthor, String imageComment, Int32? imageLevel, System.Collections.Generic.List<Com.Piwigo.Lib.DTO.PwgTag> imageTags); 9 Boolean DeleteImage(Int32 imageId, String SecurityToken); 10 Com.Piwigo.Lib.DTO.PwgImageInfo getImageInfo(Int32 imageId, Int32? commentPage, Int32? commentsPerPage); 8 11 } 9 12 } -
extensions/PiwigoLib/PiwigoLib/Proxy/Helper/PwgProxyReponseHelper.cs
r11850 r11872 6 6 7 7 using Com.Piwigo.Lib.DTO.Helper; 8 using System.Xml; 9 using Com.Piwigo.Lib.DTO; 8 10 9 11 namespace Com.Piwigo.Lib.Proxy.Helper … … 11 13 internal static class PwgProxyReponseHelper 12 14 { 15 internal static void buildDicFieldFromArray<T>(List<T> values, String paramName, ref Dictionary<String, String> dcFields) 16 { 17 String FormatString = String.Empty; 18 String ParamValue = String.Empty; 19 20 Boolean firstOcc = true; 21 if (values != null) 22 { 23 foreach (T occurance in values) 24 { 25 if (firstOcc == true) 26 { 27 firstOcc = false; 28 FormatString = "{0}"; 29 } 30 else 31 { 32 FormatString = ",{0}"; 33 } 34 35 ParamValue += String.Format(FormatString,GetString(occurance)); 36 } 37 38 dcFields.Add(paramName, ParamValue); 39 } 40 } 41 42 internal static void buildDicFieldFromValue<T>(Nullable<T> nullableValue, String paramName, ref Dictionary<String, String> dcFields) where T : struct 43 { 44 if (nullableValue.HasValue) 45 { 46 buildDicFieldFromValue<T>(nullableValue.Value, paramName, ref dcFields); 47 } 48 } 49 50 internal static void buildDicFieldFromValue<T>(T value, String paramName, ref Dictionary<String, String> dcFields) 51 { 52 String FormatString = String.Empty; 53 String ParamValue = String.Empty; 54 55 FormatString = "{0}"; 56 57 ParamValue = GetString(value); 58 59 dcFields.Add(paramName, ParamValue); 60 } 61 13 62 internal static void buildQueryFromArray<T>(List<T> values, String paramName, ref Boolean firstOcc, StringBuilder queryStringBuilder) 14 63 { … … 31 80 foreach (T occurance in values) 32 81 { 33 queryStringBuilder.AppendFormat(FormatString, paramName, HttpUtility.UrlEncode( occurance.ToString().ToLower()));82 queryStringBuilder.AppendFormat(FormatString, paramName, HttpUtility.UrlEncode(GetString(occurance))); 34 83 firstOcc = false; 35 84 } … … 38 87 } 39 88 40 internal static void buildQueryFromValue<T>(Nullable<T> nullableValue, String paramName, ref Boolean firstOcc, StringBuilder queryStringBuilder) 41 where T: struct 89 internal static void buildQueryFromValue<T>(Nullable<T> nullableValue, String paramName, ref Boolean firstOcc, StringBuilder queryStringBuilder) where T : struct 42 90 { 43 91 if (nullableValue.HasValue) … … 52 100 String ParamValue = String.Empty; 53 101 54 if (value != null)55 {56 102 FormatString = "{0}={1}"; 57 103 if (firstOcc != true) … … 60 106 } 61 107 62 if (typeof(T).IsEnum) 63 { 64 ParamValue = HttpUtility.UrlEncode(PwgEnumHelper<T>.StringValueOf(value)); 65 } 66 else 67 { 68 ParamValue = HttpUtility.UrlEncode(value.ToString().ToLower()); 69 } 108 ParamValue = HttpUtility.UrlEncode(GetString(value)); 70 109 71 110 queryStringBuilder.AppendFormat(FormatString, paramName, ParamValue); 72 111 73 112 firstOcc = false; 113 } 114 115 public static String GetString<T>(T value) 116 { 117 String strRet = String.Empty; 118 if (value is String) 119 { 120 strRet = (value as String); 74 121 } 122 else if (typeof(T).IsEnum) 123 { 124 strRet = PwgEnumHelper<T>.StringValueOf(value); 125 } 126 else if (value is PwgTag) 127 { 128 129 strRet = (value as PwgTag).Name; 130 } 131 else 132 { 133 134 strRet = (value as Object).ToString().ToLowerInvariant(); 135 } 136 137 return strRet; 75 138 } 76 139 } -
extensions/PiwigoLib/PiwigoLib/Proxy/PwgGenericProxy.cs
r11850 r11872 46 46 Request.UserAgent = PwgConfigProxy.PwgUserAgent; 47 47 Request.KeepAlive = PwgConfigProxy.PwgKeepAlive; 48 #if DEBUG 49 Request.Timeout = PwgConfigProxy.PwgTimeOutInSecond * 1000 * 1000; 50 #else 48 51 Request.Timeout = PwgConfigProxy.PwgTimeOutInSecond * 1000; 52 #endif 53 49 54 Request.CookieContainer = PwgConfigProxy.cookieContainer; // get session cookie 50 55 … … 105 110 Request.UserAgent = PwgConfigProxy.PwgUserAgent; 106 111 Request.KeepAlive = PwgConfigProxy.PwgKeepAlive; 112 #if DEBUG 113 Request.Timeout = PwgConfigProxy.PwgTimeOutInSecond * 1000 * 1000; 114 #else 107 115 Request.Timeout = PwgConfigProxy.PwgTimeOutInSecond * 1000; 116 #endif 117 108 118 Request.CookieContainer = PwgConfigProxy.cookieContainer; // get session cookie 109 119 … … 191 201 Request.UserAgent = PwgConfigProxy.PwgUserAgent; 192 202 Request.KeepAlive = PwgConfigProxy.PwgKeepAlive; 203 #if DEBUG 204 Request.Timeout = PwgConfigProxy.PwgTimeOutInSecond * 1000 * 1000; 205 #else 193 206 Request.Timeout = PwgConfigProxy.PwgTimeOutInSecond * 1000; 207 #endif 208 Request.SendChunked = true; 209 Request.ProtocolVersion = System.Net.HttpVersion.Version11; 194 210 Request.CookieContainer = PwgConfigProxy.cookieContainer; // get session cookie 195 211 -
extensions/PiwigoLib/PiwigoLib/Proxy/PwgImagesProxy.cs
r11850 r11872 18 18 * pwg.images.addChunk 19 19 * pwg.images.addComment 20 * pwg.images.addFile 21 * pwg.images.addSimple 20 * pwg.images.addFile 21 * pwg.images.addSimple pwg_images_addSimple 22 22 * pwg.images.checkFiles 23 23 * pwg.images.checkUpload 24 * pwg.images.delete 24 * pwg.images.delete pwg_images_delete 25 25 * pwg.images.exist 26 26 * pwg.images.getInfo … … 61 61 } 62 62 63 static internal PwgBaseProxyReponse pwg_images_addSimple(FileInfo fileImage, Int32? imageId, Int32? categoryId, String imageName, String imageAuthor, String imageComment, Int32? imageLevel, String imageTags) 63 /// <summary> 64 /// pwg.images.addSimple 65 /// </summary> 66 /// <param name="fileImage"></param> 67 /// <param name="imageId"></param> 68 /// <param name="categoryId"></param> 69 /// <param name="imageName"></param> 70 /// <param name="imageAuthor"></param> 71 /// <param name="imageComment"></param> 72 /// <param name="imageLevel"></param> 73 /// <param name="imageTags"></param> 74 /// <returns></returns> 75 static internal PwgAddSimpleImageProxyResponse pwg_images_addSimple(FileInfo fileImage, Int32? imageId, Int32? categoryId, String imageName, String imageAuthor, String imageComment, Int32? imageLevel, List<PwgTag> imageTags) 64 76 { 65 Pwg BaseProxyReponse response = null;77 PwgAddSimpleImageProxyResponse response = null; 66 78 67 79 Dictionary<String, String> dcFiles = new Dictionary<string,string>(); 68 80 Dictionary<String, String> dcFields = new Dictionary<string,string>(); 69 81 String stringData = String.Empty; 82 70 83 try 71 84 { 72 85 dcFields.Add("method", "pwg.images.addSimple"); 73 if (imageId.HasValue) { dcFields.Add("image_id", imageId.Value.ToString()); }74 if (categoryId.HasValue) { dcFields.Add("category", categoryId.Value.ToString()); }75 if (imageLevel.HasValue) { dcFields.Add("level", imageLevel.Value.ToString()); }76 if (!String.IsNullOrEmpty(imageName)) { dcFields.Add("name", imageName); }77 if (!String.IsNullOrEmpty(imageAuthor)) { dcFields.Add("author", imageAuthor); }78 if (!String.IsNullOrEmpty(imageComment)) { dcFields.Add("comment", imageComment); }79 if (!String.IsNullOrEmpty(imageTags)) { dcFields.Add("tags", imageTags); }86 PwgProxyReponseHelper.buildDicFieldFromValue<Int32>(imageId, "image_id", ref dcFields); 87 PwgProxyReponseHelper.buildDicFieldFromValue<Int32>(categoryId, "category", ref dcFields); 88 PwgProxyReponseHelper.buildDicFieldFromValue<Int32>(imageLevel, "level", ref dcFields); 89 PwgProxyReponseHelper.buildDicFieldFromValue<String>(imageName, "name", ref dcFields); 90 PwgProxyReponseHelper.buildDicFieldFromValue<String>(imageAuthor, "author", ref dcFields); 91 PwgProxyReponseHelper.buildDicFieldFromValue<String>(imageComment,"comment", ref dcFields); 92 PwgProxyReponseHelper.buildDicFieldFromArray<PwgTag>(imageTags, "tags", ref dcFields); 80 93 81 94 if ((fileImage != null) && (fileImage.Exists)) … … 88 101 } 89 102 90 response = PwgGenericProxy<Pwg BaseProxyReponse>.PostAsMultiPartForm(PwgConfigProxy.PwgServeurUri, dcFiles, dcFields);103 response = PwgGenericProxy<PwgAddSimpleImageProxyResponse>.PostAsMultiPartForm(PwgConfigProxy.PwgServeurUri, dcFiles, dcFields); 91 104 } 92 105 catch (Exception ex) … … 97 110 return response; 98 111 } 112 113 /// <summary> 114 /// pwg.images.delete 115 /// </summary> 116 /// <param name="imageId"></param> 117 /// <param name="SecurityToken"></param> 118 /// <returns></returns> 119 static internal PwgBaseProxyReponse pwg_images_delete(Int32 imageId, 120 String SecurityToken) 121 { 122 PwgBaseProxyReponse response = null; 123 try 124 { 125 StringBuilder data = new StringBuilder(); 126 Boolean firstOcc = true; 127 data.Append("method=pwg.images.delete"); 128 firstOcc = false; 129 PwgProxyReponseHelper.buildQueryFromValue<Int32>(imageId, "image_id", ref firstOcc, data); 130 PwgProxyReponseHelper.buildQueryFromValue<String>(SecurityToken, "pwg_token", ref firstOcc, data); 131 132 response = PwgGenericProxy<PwgBaseProxyReponse>.Post( 133 PwgConfigProxy.PwgServeurUri, 134 data.ToString()); 135 } 136 catch (Exception ex) 137 { 138 throw new PwgProxyException("pwg_images_delete", ex); 139 } 140 141 return response; 142 } 143 144 static internal PwgImageInfoProxyResponse pwg_images_getInfos(Int32 imageId, Int32? commentPage, Int32? commentsPerPage) 145 { 146 PwgImageInfoProxyResponse response = null; 147 try 148 { 149 StringBuilder data = new StringBuilder(); 150 Boolean firstOcc = true; 151 data.Append("method=pwg.images.getInfo"); 152 firstOcc = false; 153 PwgProxyReponseHelper.buildQueryFromValue<Int32>(imageId, "image_id", ref firstOcc, data); 154 PwgProxyReponseHelper.buildQueryFromValue<Int32>(commentPage, "comments_page", ref firstOcc, data); 155 PwgProxyReponseHelper.buildQueryFromValue<Int32>(commentsPerPage, "comments_per_page", ref firstOcc, data); 156 157 response = PwgGenericProxy<PwgImageInfoProxyResponse>.Post( 158 PwgConfigProxy.PwgServeurUri, 159 data.ToString()); 160 } 161 catch (Exception ex) 162 { 163 throw new PwgProxyException("pwg_images_getInfos", ex); 164 } 165 166 return response; 167 } 168 99 169 } 100 170 -
extensions/PiwigoLib/PiwigoLib/Proxy/Response/PwgImagesProxyResponse.cs
r7160 r11872 8 8 namespace Com.Piwigo.Lib.Proxy.Response 9 9 { 10 [Serializable()] 11 [XmlRoot(ElementName = "rsp")] 12 public class PwgAddSimpleImageProxyResponse : PwgBaseProxyReponse 13 { 14 [XmlElement("image_id")] 15 public Int32 Id { get; set; } 16 [XmlElement("url")] 17 public String UrlImage { get; set; } 18 } 10 19 11 20 [Serializable()] … … 23 32 [Serializable()] 24 33 [XmlRoot(ElementName = "categorie")] 25 public class PwgImageProxyResponse 34 public class PwgImageProxyResponse 26 35 { 27 36 [XmlAttribute(AttributeName = "id")] … … 41 50 [XmlAttribute(AttributeName = "hit")] 42 51 public Int64 Counter { get; set; } 52 [XmlAttribute(AttributeName = "date_creation")] 53 public String CreatingDate { get; set; } 54 [XmlAttribute(AttributeName = "date_available")] 55 public String AvailableDate { get; set; } 43 56 44 57 [XmlArray("tags")] … … 50 63 public PwgCategoryProxyResponse[] Categories { get; set; } 51 64 65 } 66 67 [Serializable()] 68 [XmlRoot(ElementName = "rsp")] 69 public class PwgImageInfoProxyResponse : PwgBaseProxyReponse 70 { 71 [XmlElement("image")] 72 public PwgImageInfoImageProxyResponse ImageInfo { get; set; } 73 } 74 75 [Serializable()] 76 [XmlRoot(ElementName = "image")] 77 public class PwgImageInfoImageProxyResponse 78 { 79 [XmlAttribute(AttributeName = "id")] 80 public Int32 Id { get; set; } 81 [XmlAttribute(AttributeName = "width")] 82 public Int32 Width { get; set; } 83 [XmlAttribute(AttributeName = "height")] 84 public Int32 Height { get; set; } 85 [XmlAttribute(AttributeName = "file")] 86 public String File { get; set; } 87 [XmlAttribute(AttributeName = "tn_url")] 88 public String UrlThunb { get; set; } 89 [XmlAttribute(AttributeName = "element_url")] 90 public String UrlElement { get; set; } 91 [XmlAttribute(AttributeName = "high_url")] 92 public String UrlHighDef { get; set; } 93 [XmlAttribute(AttributeName = "hit")] 94 public Int64 Counter { get; set; } 95 [XmlAttribute(AttributeName = "date_creation")] 96 public String CreatingDate { get; set; } 97 [XmlAttribute(AttributeName = "date_available")] 98 public String AvailableDate { get; set; } 99 [XmlAttribute(AttributeName = "tn_ext")] 100 public String ExtThumbail { get; set; } 101 [XmlAttribute(AttributeName = "author")] 102 public String Author { get; set; } 103 [XmlAttribute(AttributeName = "filesize")] 104 public Int64 ImageFileSize { get; set; } 105 [XmlAttribute(AttributeName = "date_metadata_update")] 106 public String DateUpdateMetaData { get; set; } 107 [XmlAttribute(AttributeName = "has_high")] 108 public Boolean hasHighDef { get; set; } 109 [XmlAttribute(AttributeName = "high_filesize")] 110 public Int64 HighDefFileSize { get; set; } 111 [XmlAttribute(AttributeName = "level")] 112 public Int32 ConfidentialLevel { get; set; } 113 [XmlAttribute(AttributeName = "md5sum")] 114 public String mdSum { get; set; } 115 [XmlAttribute(AttributeName = "added_by")] 116 public Int32 UserIdAddedBy { get; set; } 117 118 [XmlElement("name")] 119 public String Name { get; set; } 120 121 [XmlArray("tags")] 122 [XmlArrayItem("tag")] 123 public PwgTagProxyResponse[] Tags { get; set; } 124 125 [XmlArray("categories")] 126 [XmlArrayItem("category")] 127 public PwgCategoryProxyResponse[] Categories { get; set; } 128 129 [XmlElement("rates")] 130 public PwgImageRateProxyResponse ImageRate { get; set; } 131 132 [XmlElement("comments")] 133 public PwgCommentPageProxyResponse ImageComments { get; set; } 134 135 [XmlElement("comment_post")] 136 public PwgPostCommentSecurityInfo PostCommenSecurityData { get; set; } 137 } 138 139 [Serializable()] 140 [XmlRoot(ElementName = "comment_post")] 141 public class PwgPostCommentSecurityInfoProxyResponse 142 { 143 [XmlAttribute(AttributeName = "author")] 144 public String Author { get; set; } 145 [XmlAttribute(AttributeName = "key")] 146 public String AllowPostKey { get; set; } 147 } 148 149 [Serializable()] 150 [XmlRoot(ElementName = "comments")] 151 public class PwgCommentPageProxyResponse 152 { 153 [XmlAttribute("page")] 154 public Int32 Page { get; set; } 155 [XmlAttribute("per_page")] 156 public Int32 PerPage { get; set; } 157 [XmlAttribute("count")] 158 public Int32 CountOf { get; set; } 159 [XmlAttribute("nb_comments")] 160 public Int32 TotalCommentNumber { get; set; } 161 162 [XmlElement("comment", typeof(PwgCommentProxyResponse))] 163 public PwgCommentProxyResponse[] Comments { get; set; } 164 } 165 166 [Serializable()] 167 [XmlRoot(ElementName = "comments")] 168 public class PwgCommentProxyResponse 169 { 170 [XmlAttribute("id")] 171 public Int32 Id { get; set; } 172 [XmlAttribute("date")] 173 public DateTime CommentDate { get; set; } 174 [XmlAttribute("author")] 175 public String Author { get; set; } 176 [XmlAttribute("content")] 177 public String Content { get; set; } 52 178 } 53 179 -
extensions/PiwigoLib/PiwigoLib/Service/PwgImagesService.cs
r11850 r11872 49 49 } 50 50 51 public Boolean addImageByMultiPartForm(FileInfo fileImage, Int32? imageId, Int32? categoryId, String imageName, String imageAuthor, String imageComment, Int32? imageLevel, StringimageTags)52 { 53 Boolean returnValue = false;54 55 try 56 { 57 Pwg BaseProxyReponse response = PwgImagesProxy.pwg_images_addSimple(fileImage,imageId, categoryId, imageName, imageAuthor, imageComment, imageLevel, imageTags);51 public PwgImageAdded addImageByMultiPartForm(FileInfo fileImage, Int32? imageId, Int32? categoryId, String imageName, String imageAuthor, String imageComment, Int32? imageLevel, List<PwgTag> imageTags) 52 { 53 PwgImageAdded returnValue = new PwgImageAdded(); 54 55 try 56 { 57 PwgAddSimpleImageProxyResponse response = PwgImagesProxy.pwg_images_addSimple(fileImage, imageId, categoryId, imageName, imageAuthor, imageComment, imageLevel, imageTags); 58 58 59 59 if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok) … … 72 72 else 73 73 { 74 returnValue = ConvertProxyResponseToDTO(response); 75 } 76 } 77 catch (PwgProxyException ex) 78 { 79 throw new PwgServiceException("addImageByMultiPartForm : a error is raised by proxy.", ex); 80 } 81 return returnValue; 82 } 83 84 public Boolean DeleteImage(Int32 imageId, String SecurityToken) 85 { 86 Boolean returnValue = false; 87 88 try 89 { 90 91 PwgBaseProxyReponse response = PwgImagesProxy.pwg_images_delete(imageId, SecurityToken); 92 93 if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok) 94 { 95 if (response.Erreur != null) 96 { 97 throw new PwgServiceException("DeleteImage, the server has return the error.", 98 response.Erreur.Code, 99 response.Erreur.Message); 100 } 101 else 102 { 103 throw new PwgServiceException("DeleteImage : a error occurs during server process."); 104 } 105 } 106 else 107 { 74 108 returnValue = true; 75 109 } … … 77 111 catch (PwgProxyException ex) 78 112 { 79 throw new PwgServiceException("addImageByMultiPartForm : a error is raised by proxy.", ex); 80 } 81 return returnValue; 82 } 113 throw new PwgServiceException("DeleteImage : a error is raised by proxy.", ex); 114 } 115 return returnValue; 116 } 117 118 public PwgImageInfo getImageInfo(Int32 imageId, Int32? commentPage, Int32? commentsPerPage) 119 { 120 PwgImageInfo returnValue = new PwgImageInfo(); 121 122 try 123 { 124 PwgImageInfoProxyResponse response = PwgImagesProxy.pwg_images_getInfos(imageId, commentPage, commentsPerPage); 125 126 if (response.Retour != PwgBaseProxyReponseRetourEnum.Ok) 127 { 128 if (response.Erreur != null) 129 { 130 throw new PwgServiceException("RateImage, the server has return the error.", 131 response.Erreur.Code, 132 response.Erreur.Message); 133 } 134 else 135 { 136 throw new PwgServiceException("RateImage : a error occurs during server process."); 137 } 138 } 139 else 140 { 141 //returnValue = ConvertProxyResponseToDTO(response); 142 } 143 } 144 catch (PwgProxyException ex) 145 { 146 throw new PwgServiceException("RateImage : a error is raised by proxy.", ex); 147 } 148 return returnValue; 149 } 150 /// <summary> 151 /// private: convert response to dto object 152 /// </summary> 153 /// <param name="response"></param> 154 /// <param name="session"></param> 155 internal static PwgImageAdded ConvertProxyResponseToDTO(PwgAddSimpleImageProxyResponse response) 156 { 157 PwgImageAdded returnValue = new PwgImageAdded(); 158 159 returnValue.Id = response.Id; 160 161 if (String.IsNullOrEmpty(response.UrlImage)) 162 { 163 returnValue.UrlElement = null; 164 } 165 else 166 { 167 returnValue.UrlElement = (new UriBuilder(response.UrlImage)).Uri; 168 } 169 170 return returnValue; 171 } 172 83 173 84 174 /// <summary> … … 163 253 returnValue.Width = response.Width; 164 254 255 if (response.AvailableDate != null) 256 { 257 DateTime tryDate; 258 if (DateTime.TryParse(response.AvailableDate, out tryDate)) 259 { 260 returnValue.AvailableDate = tryDate; 261 } 262 } 263 264 if (response.CreatingDate != null) 265 { 266 DateTime tryDate; 267 if (DateTime.TryParse(response.CreatingDate, out tryDate)) 268 { 269 returnValue.CreatingDate = tryDate; 270 } 271 } 272 165 273 if (String.IsNullOrEmpty(response.UrlElement)) 166 274 { -
extensions/PiwigoLib/TestPiwigoLib/Form1.cs
r11850 r11872 50 50 //Int32 Count = 0; 51 51 52 //List<PwgImage> lstImg = PwgServiceProvider.Instance.PwgTagsService.GetListOfImagesFormTags(new List<Int32>() { 1, 7 },52 //List<PwgImage> lstImgTag = PwgServiceProvider.Instance.PwgTagsService.GetListOfImagesFormTags(new List<Int32>() { 1, 7 }, 53 53 // null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 54 54 // ref Page, ref PerPage, ref Count); 55 55 56 //List<PwgImage> lstImg = PwgServiceProvider.Instance.PwgCategoriesService.GetListOfImagesFormCategory(1,56 //List<PwgImage> lstImgCat = PwgServiceProvider.Instance.PwgCategoriesService.GetListOfImagesFormCategory(1, 57 57 // null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 58 58 // ref Page, ref PerPage, ref Count); … … 74 74 //lstCat = PwgServiceProvider.Instance.PwgCategoriesService.GetAdminListOfCategory(); 75 75 76 FileInfo fi = new FileInfo("C:\\Users\\bayral\\Downloads\\49133_1636405570_2648232_n.jpg"); 77 rc = PwgServiceProvider.Instance.PwgImagesService.addImageByMultiPartForm(fi, null, 1, "benoit", "byarl", "test upload", 0, null); 76 //FileInfo fi = new FileInfo("C:\\Users\\bayral\\Downloads\\49133_1636405570_2648232_n.jpg"); 77 //PwgImageAdded imgAdd = PwgServiceProvider.Instance.PwgImagesService.addImageByMultiPartForm(fi, null, 1, "benoit", "byarl", "test upload", 0, new List<PwgTag>() { new PwgTag() { Name = "Benoit" }, new PwgTag() { Name = "Noé" } }); 78 79 rc = PwgServiceProvider.Instance.PwgImagesService.DeleteImage(319, sess.SecurityToken); 80 81 PwgImageInfo info = PwgServiceProvider.Instance.PwgImagesService.getImageInfo(319, null, null); 78 82 79 83 //PwgImageRate imgRate = PwgServiceProvider.Instance.PwgImagesService.RateImage(1, 5);
Note: See TracChangeset
for help on using the changeset viewer.