1 | using System; |
---|
2 | using System.Windows.Forms; |
---|
3 | |
---|
4 | using Com.Piwigo.Lib.IService; |
---|
5 | using Com.Piwigo.Lib.DTO; |
---|
6 | using System.Collections.Generic; |
---|
7 | using System.IO; |
---|
8 | |
---|
9 | |
---|
10 | namespace TestPiwigoLib |
---|
11 | { |
---|
12 | public partial class Form1 : Form |
---|
13 | { |
---|
14 | public Form1() |
---|
15 | { |
---|
16 | InitializeComponent(); |
---|
17 | } |
---|
18 | |
---|
19 | private void Form1_Load(object sender, EventArgs e) |
---|
20 | { |
---|
21 | } |
---|
22 | |
---|
23 | private void button1_Click(object sender, EventArgs e) |
---|
24 | { |
---|
25 | UriBuilder urib = new UriBuilder(); |
---|
26 | urib.Host = tbServer.Text; |
---|
27 | urib.Path = "/ws.php"; |
---|
28 | urib.Scheme = "http://"; |
---|
29 | |
---|
30 | PwgServiceProvider.Instance.PwgSetupService.Setup("TestPiwigoLib", null, urib.Uri); |
---|
31 | |
---|
32 | |
---|
33 | Console.WriteLine(urib.Uri.AbsoluteUri); |
---|
34 | |
---|
35 | try |
---|
36 | { |
---|
37 | PwgSession sess = null; |
---|
38 | sess = PwgServiceProvider.Instance.PwgSessionService.GetPwgSession(); |
---|
39 | Console.WriteLine("user : " + sess.UserName + " " + sess.Status); |
---|
40 | |
---|
41 | sess = PwgServiceProvider.Instance.PwgSessionService.Login(tbUser.Text, tbPassword.Text); |
---|
42 | Console.WriteLine("user : " + sess.UserName + " " + sess.Status); |
---|
43 | |
---|
44 | //Boolean rc = PwgServiceProvider.Instance.PwgTagsService.AddTag("Loic"); |
---|
45 | |
---|
46 | //List<PwgTag> lstTag = PwgServiceProvider.Instance.PwgTagsService.GetAdminListOfTag(); |
---|
47 | |
---|
48 | //Int32 Page = 0; |
---|
49 | //Int32 PerPage = 0; |
---|
50 | //Int32 Count = 0; |
---|
51 | |
---|
52 | //List<PwgImage> lstImg = PwgServiceProvider.Instance.PwgTagsService.GetListOfImagesFormTags(new List<Int32>() { 1, 7 }, |
---|
53 | // null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, |
---|
54 | // ref Page, ref PerPage, ref Count); |
---|
55 | |
---|
56 | //List<PwgImage> lstImg = PwgServiceProvider.Instance.PwgCategoriesService.GetListOfImagesFormCategory(1, |
---|
57 | // null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, |
---|
58 | // ref Page, ref PerPage, ref Count); |
---|
59 | |
---|
60 | //Console.WriteLine("lstImg : Page " + Page.ToString() + " PerPage " + PerPage); |
---|
61 | |
---|
62 | //List<PwgCategory> lstCat = PwgServiceProvider.Instance.PwgCategoriesService.GetAdminListOfCategory(); |
---|
63 | |
---|
64 | Int32 newid = 0; |
---|
65 | String msg = String.Empty; |
---|
66 | Boolean rc; |
---|
67 | // rc = PwgServiceProvider.Instance.PwgCategoriesService.AddCategory("test_cat", 1, ref newid, ref msg); |
---|
68 | //List<PwgCategory> lstCat = PwgServiceProvider.Instance.PwgCategoriesService.GetAdminListOfCategory(); |
---|
69 | //Console.WriteLine(String.Format("newid : {0} message : {1}", newid,msg)); |
---|
70 | //rc = PwgServiceProvider.Instance.PwgCategoriesService.UpdateCategoryInfo(newid, "test2", "rename cat"); |
---|
71 | //Boolean rc = PwgServiceProvider.Instance.PwgCategoriesService.DeleteCategory(newid, sess.SecurityToken, PwgCategoryPhotoDeletionModeEnum.None); |
---|
72 | //rc = PwgServiceProvider.Instance.PwgCategoriesService.MoveCategory(new List<Int32>() { newid }, PwgCategory.RootCategoryId, sess.SecurityToken); |
---|
73 | |
---|
74 | //lstCat = PwgServiceProvider.Instance.PwgCategoriesService.GetAdminListOfCategory(); |
---|
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); |
---|
78 | |
---|
79 | //PwgImageRate imgRate = PwgServiceProvider.Instance.PwgImagesService.RateImage(1, 5); |
---|
80 | |
---|
81 | sess = PwgServiceProvider.Instance.PwgSessionService.Logout(); |
---|
82 | Console.WriteLine("user : " + sess.UserName + " " + sess.Status); |
---|
83 | } |
---|
84 | catch (PwgServiceException ex) |
---|
85 | { |
---|
86 | Console.WriteLine("Erreur " + ex.NumeroErr + " " + ex.MessageErr); |
---|
87 | Console.WriteLine(ex.Message); |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | private void Form1_FormClosing(object sender, FormClosingEventArgs e) |
---|
92 | { |
---|
93 | global::TestPiwigoLib.Properties.Settings.Default.Save(); |
---|
94 | } |
---|
95 | } |
---|
96 | } |
---|