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

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

root category handled

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