source: extensions/PiwigoLib/PiwigoWpf/Command/PwgCmdConnect.cs @ 11850

Last change on this file since 11850 was 11850, checked in by bayral, 13 years ago

MAj des truc existant et debut du upload de fichier

File size: 2.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using Com.Piwigo.Lib.IService;
4using Com.Piwigo.Wpf.DTO;
5using Com.Piwigo.Lib.DTO;
6using Com.Piwigo.Wpf.DTO.Helper;
7using Com.Piwigo.Wpf.Helper;
8
9namespace 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}
Note: See TracBrowser for help on using the repository browser.