1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using Com.Piwigo.Lib.IService; |
---|
4 | using Com.Piwigo.Wpf.DTO; |
---|
5 | using Com.Piwigo.Lib.DTO; |
---|
6 | using Com.Piwigo.Wpf.DTO.Helper; |
---|
7 | using Com.Piwigo.Wpf.Helper; |
---|
8 | |
---|
9 | namespace Com.Piwigo.Wpf.Command |
---|
10 | { |
---|
11 | public sealed class PwgCmdConnect : PwgCmdBase |
---|
12 | { |
---|
13 | public override Boolean CanExecute(object parameter) |
---|
14 | { |
---|
15 | Boolean retVal = false; |
---|
16 | if ( AppHelper.IsInDesignModeStatic == true) |
---|
17 | { |
---|
18 | retVal = false; |
---|
19 | } |
---|
20 | else |
---|
21 | { |
---|
22 | if ((PwgModelManager.Instance.Session != null) |
---|
23 | & (PwgModelManager.Instance.Session.ServeurName != null)) |
---|
24 | { |
---|
25 | retVal = !String.IsNullOrWhiteSpace(PwgModelManager.Instance.Session.ServeurName); |
---|
26 | } |
---|
27 | } |
---|
28 | return (retVal); |
---|
29 | } |
---|
30 | |
---|
31 | public override void Execute(object parameter) |
---|
32 | { |
---|
33 | try { |
---|
34 | Uri uriServer = new Uri(PwgModelManager.Instance.Session.ServeurName); |
---|
35 | |
---|
36 | PwgServiceProvider.Instance.PwgSetupService.Setup(null, null, uriServer); |
---|
37 | PwgSession sess = PwgServiceProvider.Instance.PwgSessionService.GetPwgSession(); |
---|
38 | sess = PwgServiceProvider.Instance.PwgSessionService.Login( PwgModelManager.Instance.Session.UserName, |
---|
39 | PwgModelManager.Instance.Session.Password); |
---|
40 | |
---|
41 | PwgSessionWPF sesWPF = PwgModelManager.Instance.Session; |
---|
42 | PwgSessionWPFHelper.AddPwgSessionInfoToPwgSessionWPF(sess, ref sesWPF); |
---|
43 | |
---|
44 | List<PwgCategory> lstCat = PwgServiceProvider.Instance.PwgCategoriesService.GetListOfCategory(null, false, (PwgModelManager.Instance.Session.Status == PwgSessionStatusEnum.Guest)); |
---|
45 | PwgCategoryListWPF lstCatWPF = PwgModelManager.Instance.CategoryList; |
---|
46 | |
---|
47 | PwgCategoryListWPFHelper.ConvertPwgCategoryListToPwgCategoryListWPF(lstCat, ref lstCatWPF); |
---|
48 | } |
---|
49 | catch (PwgServiceException ex) |
---|
50 | { |
---|
51 | Console.WriteLine("Erreur " + ex.NumeroErr + " " + ex.MessageErr); |
---|
52 | Console.WriteLine(ex.Message); |
---|
53 | } |
---|
54 | |
---|
55 | } |
---|
56 | } |
---|
57 | } |
---|