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 | using Com.Piwigo.Wpf.Service; |
---|
9 | |
---|
10 | namespace Com.Piwigo.Wpf.Command |
---|
11 | { |
---|
12 | public sealed class PwgCmdConnect : PwgCmdBase |
---|
13 | { |
---|
14 | public override void Execute(object parameter) |
---|
15 | { |
---|
16 | try { |
---|
17 | IsRunning = true; |
---|
18 | Uri uriServer = new Uri(PwgModelManager.Instance.Session.ServeurName); |
---|
19 | |
---|
20 | PwgServiceProvider.Instance.PwgSetupService.Setup(null, null, uriServer); |
---|
21 | PwgSession sess = PwgServiceProvider.Instance.PwgSessionService.GetPwgSession(); |
---|
22 | sess = PwgServiceProvider.Instance.PwgSessionService.Login( PwgModelManager.Instance.Session.UserName, |
---|
23 | PwgModelManager.Instance.Session.Password); |
---|
24 | |
---|
25 | PwgSessionWPF sesWPF = PwgModelManager.Instance.Session; |
---|
26 | PwgSessionWPFHelper.AddPwgSessionInfoToPwgSessionWPF(sess, ref sesWPF); |
---|
27 | |
---|
28 | List<PwgCategory> lstCat = PwgServiceProvider.Instance.PwgCategoriesService.GetListOfCategory(null, false, null); //(PwgModelManager.Instance.Session.Status == PwgSessionStatusEnum.Guest) |
---|
29 | PwgCategoryListWPF lstCatWPF = PwgModelManager.Instance.CategoryList; |
---|
30 | |
---|
31 | PwgCategoryListWPFHelper.ConvertPwgCategoryListToPwgCategoryListWPF(lstCat, ref lstCatWPF); |
---|
32 | |
---|
33 | ImageCacheManager.Instance.SetCurrentServer(uriServer.AbsoluteUri); |
---|
34 | IsRunning = false; |
---|
35 | } |
---|
36 | catch (PwgServiceException ex) |
---|
37 | { |
---|
38 | Console.WriteLine("Erreur " + ex.NumeroErr + " " + ex.MessageErr); |
---|
39 | Console.WriteLine(ex.Message); |
---|
40 | } |
---|
41 | |
---|
42 | } |
---|
43 | } |
---|
44 | } |
---|