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 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 Album ..."); |
---|
29 | if (PwgModelManager.Instance.ImageList != null) |
---|
30 | { |
---|
31 | PwgModelManager.Instance.ImageList.Clear(); |
---|
32 | } |
---|
33 | |
---|
34 | if ((PwgModelManager.Instance.AlbumList != null) |
---|
35 | && (PwgModelManager.Instance.RootAlbumList != null)) |
---|
36 | { |
---|
37 | PwgModelManager.Instance.RootAlbumList.Childrens.Clear(); |
---|
38 | } |
---|
39 | |
---|
40 | if (PwgModelManager.Instance.AlbumList != null) |
---|
41 | { |
---|
42 | PwgModelManager.Instance.AlbumList.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 | } |
---|