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

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

firsts steps of wpf client

File size: 1.9 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;
8using Com.Piwigo.Wpf.Service;
9
10namespace 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}
Note: See TracBrowser for help on using the repository browser.