source: extensions/PiwigoLib/PiwigoWpf/Command/PwgCmdDisconnect.cs @ 17492

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

rename category to Albums

File size: 1.8 KB
RevLine 
[11911]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{
[11922]12    public sealed class PwgCmdDisconnect : AsyncCommand
[11911]13    {
[11922]14        public override string Text { get { return "Disconnect from server"; } }
15
16        protected override void OnExecute(object parameter)
[11911]17        {
18            try {
19                PwgSessionWPF sesWPF = PwgModelManager.Instance.Session;
20               
[11922]21                SendUiInfo("Logging out ...");
22
[11911]23                PwgSession sess = null;
24                sess = PwgServiceProvider.Instance.PwgSessionService.Logout();
25
26                PwgSessionWPFHelper.AddPwgSessionInfoToPwgSessionWPF(sess, ref sesWPF);
[11922]27
[12336]28                SendUiInfo("Removing Image and Album ...");
[11922]29                if (PwgModelManager.Instance.ImageList != null)
30                {
31                    PwgModelManager.Instance.ImageList.Clear();
32                }
33
[12336]34                if ((PwgModelManager.Instance.AlbumList != null)
35                    && (PwgModelManager.Instance.RootAlbumList != null))
[11935]36                {
[12336]37                    PwgModelManager.Instance.RootAlbumList.Childrens.Clear();
[11935]38                }
39
[12336]40                if (PwgModelManager.Instance.AlbumList != null)
[11911]41                {
[12336]42                    PwgModelManager.Instance.AlbumList.Clear();
[11911]43                }
44
[11922]45                SendUiInfo("Unset cache data ...");
[11911]46                ImageCacheManager.Instance.UnsetCurrentServer();
47            }
48            catch (PwgServiceException ex)
49            {
[11922]50                SendUiInfo("Error " + ex.NumeroErr + " " + ex.MessageErr);
[11911]51            }
52        }
53    }
54}
Note: See TracBrowser for help on using the repository browser.