1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using System.Linq; |
---|
4 | using System.Text; |
---|
5 | |
---|
6 | using Com.Piwigo.Lib.IService; |
---|
7 | using Com.Piwigo.Lib.DTO; |
---|
8 | |
---|
9 | using Com.Piwigo.Uploader.DTO; |
---|
10 | using Com.Piwigo.Uploader.Helper; |
---|
11 | |
---|
12 | namespace Com.Piwigo.Uploader.Service |
---|
13 | { |
---|
14 | public class Connect: IService |
---|
15 | { |
---|
16 | public void runService() |
---|
17 | { |
---|
18 | PwgServiceProvider.Instance.PwgSetupService.Setup("UploadToPiwigo", null, ModelManager.Instance.serveurName); |
---|
19 | |
---|
20 | System.Diagnostics.Debug.WriteLine(ModelManager.Instance.serveurName.AbsoluteUri); |
---|
21 | |
---|
22 | try |
---|
23 | { |
---|
24 | List<PwgAlbum> lstPCat = null; |
---|
25 | ModelManager.Instance.sess = PwgServiceProvider.Instance.PwgSessionService.Login( ModelManager.Instance.userName, ModelManager.Instance.password); |
---|
26 | ModelManager.Instance.isConnected = true; |
---|
27 | |
---|
28 | System.Diagnostics.Debug.WriteLine("user : " + ModelManager.Instance.sess.UserName + " " + ModelManager.Instance.sess.Status); |
---|
29 | |
---|
30 | lstPCat = PwgServiceProvider.Instance.PwgAlbumsService.GetListOfAlbum(PwgAlbum.RootAlbumId, true,null); |
---|
31 | |
---|
32 | ModelManager.Instance.resetLstCat(); |
---|
33 | |
---|
34 | foreach (PwgAlbum item in lstPCat) |
---|
35 | { |
---|
36 | ModelManager.Instance.lstCat.Add(new SelectedAlbumListItem() { ShowedValue = (String.IsNullOrWhiteSpace(item.Name) ? "album " + item.Id : item.Name), Id = item.Id, Data = item, isSelected = false }); |
---|
37 | } |
---|
38 | |
---|
39 | } |
---|
40 | catch (PwgServiceException ex) |
---|
41 | { |
---|
42 | System.Diagnostics.Debug.WriteLine(ex.Message); |
---|
43 | throw new ApplicationException ("Erreur " + ex.NumeroErr + " " + ex.MessageErr); |
---|
44 | } |
---|
45 | } |
---|
46 | } |
---|
47 | } |
---|